src/java.desktop/share/classes/java/awt/Robot.java

Print this page




 545             ite.printStackTrace();
 546         }
 547     }
 548 
 549     private void checkDelayArgument(int ms) {
 550         if (ms < 0 || ms > MAX_DELAY) {
 551             throw new IllegalArgumentException("Delay must be to 0 to 60,000ms");
 552         }
 553     }
 554 
 555     /**
 556      * Waits until all events currently on the event queue have been processed.
 557      * @throws  IllegalThreadStateException if called on the AWT event dispatching thread
 558      */
 559     public synchronized void waitForIdle() {
 560         checkNotDispatchThread();
 561 
 562         try {
 563             SunToolkit.flushPendingEvents();
 564             // 7185258: realSync() call blocks all DnD tests on OS X
 565             if (AccessController.doPrivileged(OSInfo.getOSTypeAction()) = OSInfo.OSType.MACOSX) {
 566                 // post a dummy event to the queue so we know when
 567                 // all the events before it have been processed
 568                 EventQueue.invokeAndWait( new Runnable() {
 569                                                 public void run() {
 570                                                     // dummy implementation
 571                                                 }
 572                                             } );
 573             } else {
 574                 ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
 575             }
 576         } catch(InterruptedException ite) {
 577             System.err.println("Robot.waitForIdle, non-fatal exception caught:");
 578             ite.printStackTrace();
 579         } catch(InvocationTargetException ine) {
 580             System.err.println("Robot.waitForIdle, non-fatal exception caught:");
 581             ine.printStackTrace();
 582         }
 583     }
 584 
 585     private void checkNotDispatchThread() {


 545             ite.printStackTrace();
 546         }
 547     }
 548 
 549     private void checkDelayArgument(int ms) {
 550         if (ms < 0 || ms > MAX_DELAY) {
 551             throw new IllegalArgumentException("Delay must be to 0 to 60,000ms");
 552         }
 553     }
 554 
 555     /**
 556      * Waits until all events currently on the event queue have been processed.
 557      * @throws  IllegalThreadStateException if called on the AWT event dispatching thread
 558      */
 559     public synchronized void waitForIdle() {
 560         checkNotDispatchThread();
 561 
 562         try {
 563             SunToolkit.flushPendingEvents();
 564             // 7185258: realSync() call blocks all DnD tests on OS X
 565             if (AccessController.doPrivileged(OSInfo.getOSTypeAction()) == OSInfo.OSType.MACOSX) {
 566                 // post a dummy event to the queue so we know when
 567                 // all the events before it have been processed
 568                 EventQueue.invokeAndWait( new Runnable() {
 569                                                 public void run() {
 570                                                     // dummy implementation
 571                                                 }
 572                                             } );
 573             } else {
 574                 ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
 575             }
 576         } catch(InterruptedException ite) {
 577             System.err.println("Robot.waitForIdle, non-fatal exception caught:");
 578             ite.printStackTrace();
 579         } catch(InvocationTargetException ine) {
 580             System.err.println("Robot.waitForIdle, non-fatal exception caught:");
 581             ine.printStackTrace();
 582         }
 583     }
 584 
 585     private void checkNotDispatchThread() {