< prev index next >

src/java.desktop/share/classes/java/awt/Window.java

Print this page

        

@@ -50,11 +50,10 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 import javax.accessibility.*;
 import sun.awt.AWTAccessor;
 import sun.awt.AWTPermissions;
 import sun.awt.AppContext;
-import sun.awt.CausedFocusEvent;
 import sun.awt.DebugSettings;
 import sun.awt.SunToolkit;
 import sun.awt.util.IdentityArrayList;
 import sun.java2d.pipe.Region;
 import sun.security.action.GetPropertyAction;

@@ -220,11 +219,11 @@
      * before it lost focus.
      */
     private transient Component temporaryLostComponent;
 
     static boolean systemSyncLWRequests = false;
-    boolean     syncLWRequests = false;
+    volatile boolean syncLWRequests = false;
     transient boolean beforeFirstShow = true;
     private transient boolean disposing = false;
     transient WindowDisposerRecord disposerRecord = null;
 
     static final int OPENED = 0x01;

@@ -4127,10 +4126,36 @@
 
     // a window doesn't need to be updated in the Z-order.
     @Override
     void updateZOrder() {}
 
+    /**
+     * Enables the synchronous focus requests on lightweight components in this window
+     * if {@code true} is specified and the system property
+     * {@code awt.enableSyncLWFocus} is set. Reverts to the asynchronous focus requests
+     * if the specified value is {@code false}.
+     * By default, all windows use asynchronous lightweight focus requests.
+     *
+     * The synchronous lightweight focus requests should only enabled
+     * if this window will never transfer focus to other heavyweight containers.
+     * In this case the observable focus behavior is the same as with
+     * asynchronous requests.
+     *
+     * If the window does transfer focus to other
+     * heavyweight containers and the synchronous lightweight focus requests
+     * are enabled to it then further focus behavior is unspecified.
+     *
+     * @param    enable whether to enable the lightweight focus requests
+     *
+     * @see java.awt.Component#isLightweight
+     * @since 1.9
+     */
+    public void setSyncLWFocus(boolean enable) {
+        syncLWRequests = enable && java.security.AccessController.doPrivileged(
+                new GetPropertyAction("awt.enableSyncLWFocus")) != null;
+    }
+
 } // class Window
 
 
 /**
  * This class is no longer used, but is maintained for Serialization
< prev index next >