diff --git a/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java b/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java index 75cf0e0c918..d4d4a92e88c 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java +++ b/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java @@ -324,23 +324,6 @@ public abstract class KeyboardFocusManager "downCycleDefaultFocusTraversalKeys" }; - /** - * The default strokes for initializing the default focus traversal keys. - */ - private static final AWTKeyStroke[][] defaultFocusTraversalKeyStrokes = { - { - AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, 0, false), - AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, InputEvent.CTRL_DOWN_MASK | InputEvent.CTRL_MASK, false), - }, - { - AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_DOWN_MASK | InputEvent.SHIFT_MASK, false), - AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, - InputEvent.SHIFT_DOWN_MASK | InputEvent.SHIFT_MASK | InputEvent.CTRL_DOWN_MASK | InputEvent.CTRL_MASK, - false), - }, - {}, - {}, - }; /** * The default focus traversal keys. Each array of traversal keys will be * in effect on all Windows that have no such array of their own explicitly @@ -431,6 +414,27 @@ public abstract class KeyboardFocusManager * Initializes a KeyboardFocusManager. */ public KeyboardFocusManager() { + AWTKeyStroke[][] defaultFocusTraversalKeyStrokes = { + { + AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, 0, false), + AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, + InputEvent.CTRL_DOWN_MASK | + InputEvent.CTRL_MASK, false), + }, + { + AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, + InputEvent.SHIFT_DOWN_MASK | + InputEvent.SHIFT_MASK, false), + AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, + InputEvent.SHIFT_DOWN_MASK | + InputEvent.SHIFT_MASK | + InputEvent.CTRL_DOWN_MASK | + InputEvent.CTRL_MASK, + false), + }, + {}, + {}, + }; for (int i = 0; i < TRAVERSAL_KEY_LENGTH; i++) { Set work_set = new HashSet<>(); for (int j = 0; j < defaultFocusTraversalKeyStrokes[i].length; j++) { diff --git a/jdk/src/java.desktop/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java b/jdk/src/java.desktop/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java index d189c3819ee..11b54c807c4 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java @@ -42,8 +42,10 @@ public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManag private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.focus.KeyboardFocusManagerPeerImpl"); - private static AWTAccessor.KeyboardFocusManagerAccessor kfmAccessor = - AWTAccessor.getKeyboardFocusManagerAccessor(); + private static class KfmAccessor { + private static AWTAccessor.KeyboardFocusManagerAccessor instance = + AWTAccessor.getKeyboardFocusManagerAccessor(); + } // The constants are copied from java.awt.KeyboardFocusManager public static final int SNFH_FAILURE = 0; @@ -152,12 +154,13 @@ public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManag long time, CausedFocusEvent.Cause cause) { - return kfmAccessor.shouldNativelyFocusHeavyweight( - heavyweight, descendant, temporary, focusedWindowChangeAllowed, time, cause); + return KfmAccessor.instance.shouldNativelyFocusHeavyweight( + heavyweight, descendant, temporary, focusedWindowChangeAllowed, + time, cause); } public static void removeLastFocusRequest(Component heavyweight) { - kfmAccessor.removeLastFocusRequest(heavyweight); + KfmAccessor.instance.removeLastFocusRequest(heavyweight); } // WARNING: Don't call it on the Toolkit thread. @@ -167,7 +170,8 @@ public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManag boolean focusedWindowChangeAllowed, long time) { - return kfmAccessor.processSynchronousLightweightTransfer( - heavyweight, descendant, temporary, focusedWindowChangeAllowed, time); + return KfmAccessor.instance.processSynchronousLightweightTransfer( + heavyweight, descendant, temporary, focusedWindowChangeAllowed, + time); } }