src/java.desktop/share/classes/java/awt/Robot.java
Print this page
*** 548,578 ****
throw new IllegalArgumentException("Delay must be to 0 to 60,000ms");
}
}
/**
! * Waits until all events currently on the event queue have been processed.
* @throws IllegalThreadStateException if called on the AWT event dispatching thread
*/
public synchronized void waitForIdle() {
checkNotDispatchThread();
- // post a dummy event to the queue so we know when
- // all the events before it have been processed
- try {
SunToolkit.flushPendingEvents();
! EventQueue.invokeAndWait( new Runnable() {
! public void run() {
! // dummy implementation
! }
! } );
! } catch(InterruptedException ite) {
! System.err.println("Robot.waitForIdle, non-fatal exception caught:");
! ite.printStackTrace();
! } catch(InvocationTargetException ine) {
! System.err.println("Robot.waitForIdle, non-fatal exception caught:");
! ine.printStackTrace();
! }
}
private void checkNotDispatchThread() {
if (EventQueue.isDispatchThread()) {
throw new IllegalThreadStateException("Cannot call method from the event dispatcher thread");
--- 548,565 ----
throw new IllegalArgumentException("Delay must be to 0 to 60,000ms");
}
}
/**
! * Waits until all events currently on the event queue have been processed and tries
! * to synchronize with the native windowing sub-system.
* @throws IllegalThreadStateException if called on the AWT event dispatching thread
*/
public synchronized void waitForIdle() {
checkNotDispatchThread();
SunToolkit.flushPendingEvents();
! ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
}
private void checkNotDispatchThread() {
if (EventQueue.isDispatchThread()) {
throw new IllegalThreadStateException("Cannot call method from the event dispatcher thread");