Index: java/awt/Robot.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/awt/Robot.java,v retrieving revision 1.5 diff -u -r1.5 Robot.java --- java/awt/Robot.java 11 Jan 2005 09:50:14 -0000 1.5 +++ java/awt/Robot.java 22 Feb 2005 07:06:51 -0000 @@ -40,6 +40,7 @@ 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 @@ * * Since Robot generates native windowing system events, rather than * simply inserting address@hidden 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 @@ } /** - * 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 @@ + "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"); } }