6709453: (dav)Screen flickers when a JFrame switches to fullscreen mode
authordav
Wed, 01 Dec 2010 14:43:56 +0300
changeset 7492 494fbd1859a1
parent 7244 876c9217bc41
child 7493 010ad57ed8d1
6709453: (dav)Screen flickers when a JFrame switches to fullscreen mode Reviewed-by: art, dcherepanov
jdk/src/windows/classes/sun/awt/Win32GraphicsDevice.java
--- a/jdk/src/windows/classes/sun/awt/Win32GraphicsDevice.java	Tue Nov 30 21:54:55 2010 +0300
+++ b/jdk/src/windows/classes/sun/awt/Win32GraphicsDevice.java	Wed Dec 01 14:43:56 2010 +0300
@@ -30,6 +30,7 @@
 import java.awt.GraphicsConfiguration;
 import java.awt.GraphicsEnvironment;
 import java.awt.DisplayMode;
+import java.awt.EventQueue;
 import java.awt.Frame;
 import java.awt.Rectangle;
 import java.awt.Window;
@@ -610,11 +611,18 @@
      *
      * @param w full-screen window
      */
-    protected void addFSWindowListener(Window w) {
+    protected void addFSWindowListener(final Window w) {
         // Note: even though we create a listener for Window instances of
         // fs windows they will not receive window events.
         fsWindowListener = new Win32FSWindowAdapter(this);
-        w.addWindowListener(fsWindowListener);
+
+        // Fix for 6709453. Using invokeLater to avoid listening
+        // for the events already posted to the queue.
+        EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                w.addWindowListener(fsWindowListener);
+            }
+        });
     }
 
     /**