SUGGESTED FIX
+++ Robot.java 2007-01-30 21:54:41.000000000 +0300
@@ -114,10 +114,12 @@
checkRobotAllowed();
gdLoc = screen.getDefaultConfiguration().getBounds().getLocation();
Toolkit toolkit = Toolkit.getDefaultToolkit();
if (toolkit instanceof ComponentFactory) {
peer = ((ComponentFactory)toolkit).createRobot(this, screen);
+ disposer = new RobotDisposer(peer);
+ sun.java2d.Disposer.addRecord(anchor, disposer);
}
}
/* determine if the security policy allows Robot's to be created */
private void checkRobotAllowed() {
@@ -132,10 +134,26 @@
if (device == null || device.getType() != GraphicsDevice.TYPE_RASTER_SCREEN) {
throw new IllegalArgumentException("not a valid screen device");
}
}
+ private transient Object anchor = new Object();
+
+ static class RobotDisposer implements sun.java2d.DisposerRecord {
+ private final RobotPeer peer;
+ public RobotDisposer(RobotPeer peer) {
+ this.peer = peer;
+ }
+ public void dispose() {
+ if (peer != null) {
+ peer.dispose();
+ }
+ }
+ }
+
+ private transient RobotDisposer disposer;
+
/**
* Moves mouse pointer to given screen coordinates.
* @param x X position
* @param y Y position
*/
+++ RobotPeer.java 2007-01-30 21:51:35.000000000 +0300
@@ -31,6 +31,8 @@
public void keyPress(int keycode);
public void keyRelease(int keycode);
public int getRGBPixel(int x, int y);
public int [] getRGBPixels(Rectangle bounds);
+
+ public void dispose();
}
+++ XRobotPeer.java 2007-01-30 21:57:08.000000000 +0300
@@ -22,10 +22,14 @@
XRobotPeer(GraphicsConfiguration gc) {
this.xgc = (X11GraphicsConfig)gc;
setup();
}
+ public void dispose() {
+ // does nothing
+ }
+
public void mouseMove(int x, int y) {
mouseMoveImpl(xgc, x, y);
}
public void mousePress(int buttons) {
|