src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java

Print this page

        

@@ -148,10 +148,14 @@
                 });
             }
            });
     }
 
+    public static LWCToolkit getLWCToolkit() {
+        return (LWCToolkit)Toolkit.getDefaultToolkit();
+    }
+
     @Override
     protected PlatformWindow createPlatformWindow(PeerType peerType) {
         if (peerType == PeerType.EMBEDDEDFRAME) {
             return new CPlatformEmbeddedFrame();
         } else {

@@ -405,11 +409,10 @@
 
     public int getNumberOfButtons(){
         return BUTTONS;
     }
 
-
     @Override
     public boolean isTraySupported() {
         return true;
     }
 

@@ -487,10 +490,26 @@
         }}}, c); } catch (Exception e) { e.printStackTrace(); }
 
         synchronized(ret) { return ret[0]; }
     }
 
+    /**
+     * Just a wrapper for LWCToolkit.invokeAndWait. Posts an empty event to the
+     * appropriate event queue and waits for it to finish.
+     */
+    public static void flushPendingEventsOnAppkit(final Component component) {
+        try {
+            invokeAndWait(new Runnable() {
+                @Override
+                public synchronized void run() {
+                }
+            }, component);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
     // Kicks an event over to the appropriate eventqueue and waits for it to finish
     // To avoid deadlocking, we manually run the NSRunLoop while waiting
     // Any selector invoked using ThreadUtilities performOnMainThread will be processed in doAWTRunLoop
     // The CInvocationEvent will call LWCToolkit.stopAWTRunLoop() when finished, which will stop our manual runloop
     public static void invokeAndWait(Runnable event, Component component) throws InterruptedException, InvocationTargetException {