src/share/classes/sun/awt/SunToolkit.java

Print this page




 539                     AWTAccessor.getAWTEventAccessor().setPosted(e);
 540                     ((Component)e.getSource()).dispatchEvent(e);
 541                 }
 542             }, PeerEvent.ULTIMATE_PRIORITY_EVENT);
 543         postEvent(targetToAppContext(e.getSource()), pe);
 544     }
 545 
 546     protected static final Lock flushLock = new ReentrantLock();
 547     private static boolean isFlushingPendingEvents = false;
 548 
 549     /*
 550      * Flush any pending events which haven't been posted to the AWT
 551      * EventQueue yet.
 552      */
 553     public static void flushPendingEvents()  {
 554         flushLock.lock();
 555         try {
 556             // Don't call flushPendingEvents() recursively
 557             if (!isFlushingPendingEvents) {
 558                 isFlushingPendingEvents = true;

 559                 AppContext appContext = AppContext.getAppContext();
 560                 PostEventQueue postEventQueue =
 561                     (PostEventQueue)appContext.get(POST_EVENT_QUEUE_KEY);
 562                 if (postEventQueue != null) {
 563                     postEventQueue.flush();
 564                 }
 565             }
 566         } finally {
 567             isFlushingPendingEvents = false;



 568             flushLock.unlock();
 569         }
 570     }
 571 
 572     public static boolean isPostEventQueueEmpty()  {
 573         AppContext appContext = AppContext.getAppContext();
 574         PostEventQueue postEventQueue =
 575             (PostEventQueue)appContext.get(POST_EVENT_QUEUE_KEY);
 576         if (postEventQueue != null) {
 577             return postEventQueue.noEvents();
 578         } else {
 579             return true;
 580         }
 581     }
 582 
 583     /*
 584      * Execute a chunk of code on the Java event handler thread for the
 585      * given target.  Does not wait for the execution to occur before
 586      * returning to the caller.
 587      */




 539                     AWTAccessor.getAWTEventAccessor().setPosted(e);
 540                     ((Component)e.getSource()).dispatchEvent(e);
 541                 }
 542             }, PeerEvent.ULTIMATE_PRIORITY_EVENT);
 543         postEvent(targetToAppContext(e.getSource()), pe);
 544     }
 545 
 546     protected static final Lock flushLock = new ReentrantLock();
 547     private static boolean isFlushingPendingEvents = false;
 548 
 549     /*
 550      * Flush any pending events which haven't been posted to the AWT
 551      * EventQueue yet.
 552      */
 553     public static void flushPendingEvents()  {
 554         flushLock.lock();
 555         try {
 556             // Don't call flushPendingEvents() recursively
 557             if (!isFlushingPendingEvents) {
 558                 isFlushingPendingEvents = true;
 559                 try {
 560                     AppContext appContext = AppContext.getAppContext();
 561                     PostEventQueue postEventQueue =
 562                         (PostEventQueue)appContext.get(POST_EVENT_QUEUE_KEY);
 563                     if (postEventQueue != null) {
 564                         postEventQueue.flush();
 565                     }
 566                 }
 567                 finally {
 568                     isFlushingPendingEvents = false;
 569                 }
 570             }
 571         } finally {
 572             flushLock.unlock();
 573         }
 574     }
 575 
 576     public static boolean isPostEventQueueEmpty()  {
 577         AppContext appContext = AppContext.getAppContext();
 578         PostEventQueue postEventQueue =
 579             (PostEventQueue)appContext.get(POST_EVENT_QUEUE_KEY);
 580         if (postEventQueue != null) {
 581             return postEventQueue.noEvents();
 582         } else {
 583             return true;
 584         }
 585     }
 586 
 587     /*
 588      * Execute a chunk of code on the Java event handler thread for the
 589      * given target.  Does not wait for the execution to occur before
 590      * returning to the caller.
 591      */