src/share/classes/java/awt/KeyboardFocusManager.java
Print this page
@@ -346,11 +346,11 @@
* 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];
+ 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,25 +374,25 @@
* 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;
+ 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 keyEventPostProcessors;
+ private java.util.LinkedList<KeyEventPostProcessor> keyEventPostProcessors;
/**
* Maps Windows to those Windows' most recent focus owners.
*/
- private static java.util.Map mostRecentFocusOwners = new WeakHashMap();
+ 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,11 +429,11 @@
/**
* Initializes a KeyboardFocusManager.
*/
public KeyboardFocusManager() {
for (int i = 0; i < TRAVERSAL_KEY_LENGTH; i++) {
- Set work_set = new HashSet();
+ 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,11 +1123,11 @@
}
if (keystrokes == null) {
throw new IllegalArgumentException("cannot set null Set of default focus traversal keys");
}
- Set oldKeys;
+ Set<AWTKeyStroke> oldKeys;
synchronized (this) {
for (AWTKeyStroke keystroke : keystrokes) {
if (keystroke == null) {
@@ -1151,11 +1151,11 @@
}
}
oldKeys = defaultFocusTraversalKeys[id];
defaultFocusTraversalKeys[id] =
- Collections.unmodifiableSet(new HashSet(keystrokes));
+ Collections.unmodifiableSet(new HashSet<>(keystrokes));
}
firePropertyChange(defaultFocusTraversalKeyPropertyNames[id],
oldKeys, keystrokes);
}
@@ -1697,11 +1697,11 @@
*/
public void addKeyEventDispatcher(KeyEventDispatcher dispatcher) {
if (dispatcher != null) {
synchronized (this) {
if (keyEventDispatchers == null) {
- keyEventDispatchers = new java.util.LinkedList();
+ keyEventDispatchers = new java.util.LinkedList<>();
}
keyEventDispatchers.add(dispatcher);
}
}
}
@@ -1785,11 +1785,11 @@
*/
public void addKeyEventPostProcessor(KeyEventPostProcessor processor) {
if (processor != null) {
synchronized (this) {
if (keyEventPostProcessors == null) {
- keyEventPostProcessors = new java.util.LinkedList();
+ keyEventPostProcessors = new java.util.LinkedList<>();
}
keyEventPostProcessors.add(processor);
}
}
}
@@ -1863,13 +1863,13 @@
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;
+ WeakReference<Component> weakValue = null;
if (component != null) {
- weakValue = new WeakReference(component);
+ weakValue = new WeakReference<>(component);
}
mostRecentFocusOwners.put(window, weakValue);
}
static void clearMostRecentFocusOwner(Component comp) {
Container window;
@@ -1904,11 +1904,11 @@
/*
* 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<Component> weakValue =
(WeakReference)mostRecentFocusOwners.get(window);
return weakValue == null ? null : (Component)weakValue.get();
}
/**
@@ -2646,15 +2646,15 @@
try {
if (localLightweightRequests != null) {
Component lastFocusOwner = null;
Component currentFocusOwner = null;
- for (Iterator iter = localLightweightRequests.iterator(); iter.hasNext(); ) {
+ for (Iterator<KeyboardFocusManager.LightweightFocusRequest> iter = localLightweightRequests.iterator(); iter.hasNext(); ) {
currentFocusOwner = manager.getGlobalFocusOwner();
LightweightFocusRequest lwFocusRequest =
- (LightweightFocusRequest)iter.next();
+ iter.next();
/*
* WARNING: This is based on DKFM's logic solely!
*
* We allow to trigger restoreFocus() in the dispatching process
@@ -2975,16 +2975,16 @@
HeavyweightFocusRequest hwFocusRequest = getFirstHWRequest();
if (hwFocusRequest != null) {
heavyweightRequests.removeFirst();
if (hwFocusRequest.lightweightRequests != null) {
- for (Iterator lwIter = hwFocusRequest.lightweightRequests.
+ for (Iterator<KeyboardFocusManager.LightweightFocusRequest> lwIter = hwFocusRequest.lightweightRequests.
iterator();
lwIter.hasNext(); )
{
manager.dequeueKeyEvents
- (-1, ((LightweightFocusRequest)lwIter.next()).
+ (-1, lwIter.next().
component);
}
}
}
// Fix for 4799136 - clear type-ahead markers if requests queue is empty
@@ -3060,12 +3060,12 @@
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() {
+ proxyActive = AccessController.doPrivileged(new PrivilegedAction<Field>() {
+ public Field run() {
Field field = null;
try {
field = KeyEvent.class.getDeclaredField("isProxyActive");
if (field != null) {
field.setAccessible(true);