diff options
author | Michael Koch <konqueror@gmx.de> | 2005-02-22 07:07:45 +0000 |
---|---|---|
committer | Michael Koch <konqueror@gmx.de> | 2005-02-22 07:07:45 +0000 |
commit | cb4a64992bc27de91c96b6780e67d03516fe7daf (patch) | |
tree | 558204ce60784c441fac1a8d4ece6a92d11d438a | |
parent | c79a49e6c2df666b7dc792236d8bfe872c595950 (diff) | |
download | classpath-cb4a64992bc27de91c96b6780e67d03516fe7daf.tar.gz |
2005-02-22 Thomas Fitzsimmons <fitzsim@redhat.com>
* java/awt/Robot.java (waitForIdle): Call invokeAndWait on an
empty Runnable.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | java/awt/Robot.java | 28 |
2 files changed, 20 insertions, 13 deletions
@@ -1,3 +1,8 @@ +2005-02-22 Thomas Fitzsimmons <fitzsim@redhat.com> + + * java/awt/Robot.java (waitForIdle): Call invokeAndWait on an + empty Runnable. + 2005-02-21 Bryce McKinlay <mckinlay@redhat.com> * java/io/ObjectInputStream.java (readClassDescriptor): Cache result diff --git a/java/awt/Robot.java b/java/awt/Robot.java index 49726c8a1..23b6f8104 100644 --- a/java/awt/Robot.java +++ b/java/awt/Robot.java @@ -40,6 +40,7 @@ package java.awt; import gnu.java.awt.ClasspathToolkit; +import java.lang.reflect.InvocationTargetException; import java.awt.event.InputEvent; import java.awt.image.BufferedImage; import java.awt.peer.RobotPeer; @@ -53,8 +54,8 @@ import java.awt.peer.RobotPeer; * * Since Robot generates native windowing system events, rather than * simply inserting {@link AWTEvents} on the AWT event queue, its use - * is not restricted to Java programs. It can be to programatically - * drive any graphical application. + * is not restricted to Java programs. It can be used to + * programatically drive any graphical application. * * This implementation requires an X server that supports the XTest * extension. @@ -384,7 +385,8 @@ public class Robot } /** - * Wait until the event dispatch thread is idle. + * Wait until all events currently on the event queue have been + * dispatched. */ public void waitForIdle () { @@ -393,17 +395,17 @@ public class Robot + "the event dispatch thread"); EventQueue q = Toolkit.getDefaultToolkit ().getSystemEventQueue (); - - while (q.peekEvent () != null) + try + { + q.invokeAndWait (new Runnable () { public void run () { } }); + } + catch (InterruptedException e) + { + System.err.println ("Robot: waitForIdle interrupted"); + } + catch (InvocationTargetException e) { - try - { - wait (); - } - catch (InterruptedException e) - { - System.err.println ("Robot: waitForIdle interrupted"); - } + System.err.println ("Robot: waitForIdle cannot invoke target"); } } |