2005-02-22 Thomas Fitzsimmons <fitzsim@redhat.com>
+ * java/awt/Robot.java (waitForIdle): Call invokeAndWait on an
+ empty Runnable.
+
PR libgcj/17952:
* gnu/java/awt/peer/gtk/GtkWindowPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
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;
*
* 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.
}
/**
- * Wait until the event dispatch thread is idle.
+ * Wait until all events currently on the event queue have been
+ * dispatched.
*/
public void waitForIdle ()
{
+ "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");
}
}