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

Print this page

        

@@ -28,10 +28,11 @@
 import java.awt.*;
 import java.awt.Dialog.ModalityType;
 import java.awt.event.*;
 import java.awt.peer.WindowPeer;
 import java.beans.*;
+import java.lang.reflect.InvocationTargetException;
 import java.util.List;
 
 import javax.swing.*;
 
 import sun.awt.*;

@@ -855,11 +856,20 @@
         }
     }
 
     private void flushBuffers() {
         if (isVisible() && !nativeBounds.isEmpty()) {
-            LWCToolkit.getLWCToolkit().flushPendingEventsOnAppkit(target);
+            try {
+                LWCToolkit.invokeAndWait(new Runnable() {
+                    @Override
+                    public void run() {
+                        //Posting an empty to flush the EventQueue without blocking the main thread
+                    }
+                }, target);
+            } catch (InterruptedException | InvocationTargetException e) {
+                e.printStackTrace();
+            }
         }
     }
 
     /*************************************************************
      * Callbacks from the AWTWindow and AWTView objc classes.