jdk/src/java.desktop/share/classes/java/awt/EventQueue.java
changeset 47192 d46b91465a81
parent 47183 03c1b9f44ba2
child 47193 b12ec990a6b1
equal deleted inserted replaced
47191:8c95ea7056b7 47192:d46b91465a81
   717                     dispatchEventImpl(event, src);
   717                     dispatchEventImpl(event, src);
   718                 } else {
   718                 } else {
   719                     fwDispatcher.scheduleDispatch(new Runnable() {
   719                     fwDispatcher.scheduleDispatch(new Runnable() {
   720                         @Override
   720                         @Override
   721                         public void run() {
   721                         public void run() {
   722                             dispatchEventImpl(event, src);
   722                             if (dispatchThread.filterAndCheckEvent(event)) {
       
   723                                 dispatchEventImpl(event, src);
       
   724                             }
   723                         }
   725                         }
   724                     });
   726                     });
   725                 }
   727                 }
   726                 return null;
   728                 return null;
   727             }
   729             }
  1006      */
  1008      */
  1007     public SecondaryLoop createSecondaryLoop() {
  1009     public SecondaryLoop createSecondaryLoop() {
  1008         return createSecondaryLoop(null, null, 0);
  1010         return createSecondaryLoop(null, null, 0);
  1009     }
  1011     }
  1010 
  1012 
       
  1013     private class FwSecondaryLoopWrapper implements SecondaryLoop {
       
  1014         final private SecondaryLoop loop;
       
  1015         final private EventFilter filter;
       
  1016 
       
  1017         public FwSecondaryLoopWrapper(SecondaryLoop loop, EventFilter filter) {
       
  1018             this.loop = loop;
       
  1019             this.filter = filter;
       
  1020         }
       
  1021 
       
  1022         @Override
       
  1023         public boolean enter() {
       
  1024             if (filter != null) {
       
  1025                 dispatchThread.addEventFilter(filter);
       
  1026             }
       
  1027             return loop.enter();
       
  1028         }
       
  1029 
       
  1030         @Override
       
  1031         public boolean exit() {
       
  1032             if (filter != null) {
       
  1033                 dispatchThread.removeEventFilter(filter);
       
  1034             }
       
  1035             return loop.exit();
       
  1036         }
       
  1037     }
       
  1038 
  1011     SecondaryLoop createSecondaryLoop(Conditional cond, EventFilter filter, long interval) {
  1039     SecondaryLoop createSecondaryLoop(Conditional cond, EventFilter filter, long interval) {
  1012         pushPopLock.lock();
  1040         pushPopLock.lock();
  1013         try {
  1041         try {
  1014             if (nextQueue != null) {
  1042             if (nextQueue != null) {
  1015                 // Forward the request to the top of EventQueue stack
  1043                 // Forward the request to the top of EventQueue stack
  1016                 return nextQueue.createSecondaryLoop(cond, filter, interval);
  1044                 return nextQueue.createSecondaryLoop(cond, filter, interval);
  1017             }
  1045             }
  1018             if (fwDispatcher != null) {
  1046             if (fwDispatcher != null) {
  1019                 return fwDispatcher.createSecondaryLoop();
  1047                 return new FwSecondaryLoopWrapper(fwDispatcher.createSecondaryLoop(), filter);
  1020             }
  1048             }
  1021             if (dispatchThread == null) {
  1049             if (dispatchThread == null) {
  1022                 initDispatchThread();
  1050                 initDispatchThread();
  1023             }
  1051             }
  1024             return new WaitDispatchSupport(dispatchThread, cond, filter, interval);
  1052             return new WaitDispatchSupport(dispatchThread, cond, filter, interval);