src/share/classes/java/awt/KeyboardFocusManager.java

Print this page

        

*** 346,356 **** * in effect on all Windows that have no such array of their own explicitly * set. Each array will also be inherited, recursively, by any child * Component of those Windows that has no such array of its own explicitly * set. */ ! private Set[] defaultFocusTraversalKeys = new Set[4]; /** * The current focus cycle root. If the focus owner is itself a focus cycle * root, then it may be ambiguous as to which Components represent the next * and previous Components to focus during normal focus traversal. In that --- 346,356 ---- * in effect on all Windows that have no such array of their own explicitly * set. Each array will also be inherited, recursively, by any child * Component of those Windows that has no such array of its own explicitly * set. */ ! private Set<AWTKeyStroke>[] defaultFocusTraversalKeys = new Set[4]; /** * The current focus cycle root. If the focus owner is itself a focus cycle * root, then it may be ambiguous as to which Components represent the next * and previous Components to focus during normal focus traversal. In that
*** 374,398 **** * include this KeyboardFocusManager unless it was explicitly re-registered * via a call to <code>addKeyEventDispatcher</code>. If no other * KeyEventDispatchers are registered, this field may be null or refer to * a List of length 0. */ ! private java.util.LinkedList keyEventDispatchers; /** * This KeyboardFocusManager's KeyEventPostProcessor chain. The List does * not include this KeyboardFocusManager unless it was explicitly * re-registered via a call to <code>addKeyEventPostProcessor</code>. * If no other KeyEventPostProcessors are registered, this field may be * null or refer to a List of length 0. */ ! private java.util.LinkedList keyEventPostProcessors; /** * Maps Windows to those Windows' most recent focus owners. */ ! private static java.util.Map mostRecentFocusOwners = new WeakHashMap(); /** * We cache the permission used to verify that the calling thread is * permitted to access the global focus state. */ --- 374,398 ---- * include this KeyboardFocusManager unless it was explicitly re-registered * via a call to <code>addKeyEventDispatcher</code>. If no other * KeyEventDispatchers are registered, this field may be null or refer to * a List of length 0. */ ! private java.util.LinkedList<KeyEventDispatcher> keyEventDispatchers; /** * This KeyboardFocusManager's KeyEventPostProcessor chain. The List does * not include this KeyboardFocusManager unless it was explicitly * re-registered via a call to <code>addKeyEventPostProcessor</code>. * If no other KeyEventPostProcessors are registered, this field may be * null or refer to a List of length 0. */ ! private java.util.LinkedList<KeyEventPostProcessor> keyEventPostProcessors; /** * Maps Windows to those Windows' most recent focus owners. */ ! private static java.util.Map<Window, WeakReference<Component>> mostRecentFocusOwners = new WeakHashMap<>(); /** * We cache the permission used to verify that the calling thread is * permitted to access the global focus state. */
*** 429,439 **** /** * Initializes a KeyboardFocusManager. */ public KeyboardFocusManager() { for (int i = 0; i < TRAVERSAL_KEY_LENGTH; i++) { ! Set work_set = new HashSet(); for (int j = 0; j < defaultFocusTraversalKeyStrokes[i].length; j++) { work_set.add(defaultFocusTraversalKeyStrokes[i][j]); } defaultFocusTraversalKeys[i] = (work_set.isEmpty()) ? Collections.EMPTY_SET --- 429,439 ---- /** * Initializes a KeyboardFocusManager. */ public KeyboardFocusManager() { for (int i = 0; i < TRAVERSAL_KEY_LENGTH; i++) { ! Set<AWTKeyStroke> work_set = new HashSet<>(); for (int j = 0; j < defaultFocusTraversalKeyStrokes[i].length; j++) { work_set.add(defaultFocusTraversalKeyStrokes[i][j]); } defaultFocusTraversalKeys[i] = (work_set.isEmpty()) ? Collections.EMPTY_SET
*** 1123,1133 **** } if (keystrokes == null) { throw new IllegalArgumentException("cannot set null Set of default focus traversal keys"); } ! Set oldKeys; synchronized (this) { for (AWTKeyStroke keystroke : keystrokes) { if (keystroke == null) { --- 1123,1133 ---- } if (keystrokes == null) { throw new IllegalArgumentException("cannot set null Set of default focus traversal keys"); } ! Set<AWTKeyStroke> oldKeys; synchronized (this) { for (AWTKeyStroke keystroke : keystrokes) { if (keystroke == null) {
*** 1151,1161 **** } } oldKeys = defaultFocusTraversalKeys[id]; defaultFocusTraversalKeys[id] = ! Collections.unmodifiableSet(new HashSet(keystrokes)); } firePropertyChange(defaultFocusTraversalKeyPropertyNames[id], oldKeys, keystrokes); } --- 1151,1161 ---- } } oldKeys = defaultFocusTraversalKeys[id]; defaultFocusTraversalKeys[id] = ! Collections.unmodifiableSet(new HashSet<>(keystrokes)); } firePropertyChange(defaultFocusTraversalKeyPropertyNames[id], oldKeys, keystrokes); }
*** 1697,1707 **** */ public void addKeyEventDispatcher(KeyEventDispatcher dispatcher) { if (dispatcher != null) { synchronized (this) { if (keyEventDispatchers == null) { ! keyEventDispatchers = new java.util.LinkedList(); } keyEventDispatchers.add(dispatcher); } } } --- 1697,1707 ---- */ public void addKeyEventDispatcher(KeyEventDispatcher dispatcher) { if (dispatcher != null) { synchronized (this) { if (keyEventDispatchers == null) { ! keyEventDispatchers = new java.util.LinkedList<>(); } keyEventDispatchers.add(dispatcher); } } }
*** 1785,1795 **** */ public void addKeyEventPostProcessor(KeyEventPostProcessor processor) { if (processor != null) { synchronized (this) { if (keyEventPostProcessors == null) { ! keyEventPostProcessors = new java.util.LinkedList(); } keyEventPostProcessors.add(processor); } } } --- 1785,1795 ---- */ public void addKeyEventPostProcessor(KeyEventPostProcessor processor) { if (processor != null) { synchronized (this) { if (keyEventPostProcessors == null) { ! keyEventPostProcessors = new java.util.LinkedList<>(); } keyEventPostProcessors.add(processor); } } }
*** 1863,1875 **** Component component) { // ATTN: component has a strong reference to window via chain // of Component.parent fields. Since WeakHasMap refers to its // values strongly, we need to break the strong link from the // value (component) back to its key (window). ! WeakReference weakValue = null; if (component != null) { ! weakValue = new WeakReference(component); } mostRecentFocusOwners.put(window, weakValue); } static void clearMostRecentFocusOwner(Component comp) { Container window; --- 1863,1875 ---- Component component) { // ATTN: component has a strong reference to window via chain // of Component.parent fields. Since WeakHasMap refers to its // values strongly, we need to break the strong link from the // value (component) back to its key (window). ! WeakReference<Component> weakValue = null; if (component != null) { ! weakValue = new WeakReference<>(component); } mostRecentFocusOwners.put(window, weakValue); } static void clearMostRecentFocusOwner(Component comp) { Container window;
*** 1904,1914 **** /* * Please be careful changing this method! It is called from * javax.swing.JComponent.runInputVerifier() using reflection. */ static synchronized Component getMostRecentFocusOwner(Window window) { ! WeakReference weakValue = (WeakReference)mostRecentFocusOwners.get(window); return weakValue == null ? null : (Component)weakValue.get(); } /** --- 1904,1914 ---- /* * Please be careful changing this method! It is called from * javax.swing.JComponent.runInputVerifier() using reflection. */ static synchronized Component getMostRecentFocusOwner(Window window) { ! WeakReference<Component> weakValue = (WeakReference)mostRecentFocusOwners.get(window); return weakValue == null ? null : (Component)weakValue.get(); } /**
*** 2646,2656 **** try { if (localLightweightRequests != null) { Component lastFocusOwner = null; Component currentFocusOwner = null; ! for (Iterator iter = localLightweightRequests.iterator(); iter.hasNext(); ) { currentFocusOwner = manager.getGlobalFocusOwner(); LightweightFocusRequest lwFocusRequest = (LightweightFocusRequest)iter.next(); --- 2646,2656 ---- try { if (localLightweightRequests != null) { Component lastFocusOwner = null; Component currentFocusOwner = null; ! for (Iterator<KeyboardFocusManager.LightweightFocusRequest> iter = localLightweightRequests.iterator(); iter.hasNext(); ) { currentFocusOwner = manager.getGlobalFocusOwner(); LightweightFocusRequest lwFocusRequest = (LightweightFocusRequest)iter.next();
*** 2975,2985 **** HeavyweightFocusRequest hwFocusRequest = getFirstHWRequest(); if (hwFocusRequest != null) { heavyweightRequests.removeFirst(); if (hwFocusRequest.lightweightRequests != null) { ! for (Iterator lwIter = hwFocusRequest.lightweightRequests. iterator(); lwIter.hasNext(); ) { manager.dequeueKeyEvents (-1, ((LightweightFocusRequest)lwIter.next()). --- 2975,2985 ---- HeavyweightFocusRequest hwFocusRequest = getFirstHWRequest(); if (hwFocusRequest != null) { heavyweightRequests.removeFirst(); if (hwFocusRequest.lightweightRequests != null) { ! for (Iterator<KeyboardFocusManager.LightweightFocusRequest> lwIter = hwFocusRequest.lightweightRequests. iterator(); lwIter.hasNext(); ) { manager.dequeueKeyEvents (-1, ((LightweightFocusRequest)lwIter.next()).
*** 3060,3071 **** static Field proxyActive; // Accessor to private field isProxyActive of KeyEvent private static boolean isProxyActiveImpl(KeyEvent e) { if (proxyActive == null) { ! proxyActive = (Field) AccessController.doPrivileged(new PrivilegedAction() { ! public Object run() { Field field = null; try { field = KeyEvent.class.getDeclaredField("isProxyActive"); if (field != null) { field.setAccessible(true); --- 3060,3071 ---- static Field proxyActive; // Accessor to private field isProxyActive of KeyEvent private static boolean isProxyActiveImpl(KeyEvent e) { if (proxyActive == null) { ! proxyActive = AccessController.doPrivileged(new PrivilegedAction<Field>() { ! public Field run() { Field field = null; try { field = KeyEvent.class.getDeclaredField("isProxyActive"); if (field != null) { field.setAccessible(true);