src/share/classes/javax/swing/JComponent.java
Print this page
@@ -2109,10 +2109,11 @@
* are pushed to the <code>KeyboardManager</code>
*/
private void registerWithKeyboardManager(boolean onlyIfNew) {
InputMap inputMap = getInputMap(WHEN_IN_FOCUSED_WINDOW, false);
KeyStroke[] strokes;
+ @SuppressWarnings("unchecked")
Hashtable<KeyStroke, KeyStroke> registered =
(Hashtable<KeyStroke, KeyStroke>)getClientProperty
(WHEN_IN_FOCUSED_WINDOW_BINDINGS);
if (inputMap != null) {
@@ -2162,10 +2163,11 @@
/**
* Unregisters all the previously registered
* <code>WHEN_IN_FOCUSED_WINDOW</code> <code>KeyStroke</code> bindings.
*/
private void unregisterWithKeyboardManager() {
+ @SuppressWarnings("unchecked")
Hashtable<KeyStroke, KeyStroke> registered =
(Hashtable<KeyStroke, KeyStroke>)getClientProperty
(WHEN_IN_FOCUSED_WINDOW_BINDINGS);
if (registered != null && registered.size() > 0) {
@@ -4124,20 +4126,24 @@
if (!getFlag(AUTOSCROLLS_SET)) {
setAutoscrolls(((Boolean)value).booleanValue());
setFlag(AUTOSCROLLS_SET, false);
}
} else if (propertyName == "focusTraversalKeysForward") {
+ @SuppressWarnings("unchecked")
+ Set<AWTKeyStroke> strokeSet = (Set<AWTKeyStroke>) value;
if (!getFlag(FOCUS_TRAVERSAL_KEYS_FORWARD_SET)) {
super.setFocusTraversalKeys(KeyboardFocusManager.
FORWARD_TRAVERSAL_KEYS,
- (Set<AWTKeyStroke>)value);
+ strokeSet);
}
} else if (propertyName == "focusTraversalKeysBackward") {
+ @SuppressWarnings("unchecked")
+ Set<AWTKeyStroke> strokeSet = (Set<AWTKeyStroke>) value;
if (!getFlag(FOCUS_TRAVERSAL_KEYS_BACKWARD_SET)) {
super.setFocusTraversalKeys(KeyboardFocusManager.
BACKWARD_TRAVERSAL_KEYS,
- (Set<AWTKeyStroke>)value);
+ strokeSet);
}
} else {
throw new IllegalArgumentException("property \""+
propertyName+ "\" cannot be set using this method");
}
@@ -4711,10 +4717,11 @@
* @since 1.3
*
* @see #getVetoableChangeListeners
* @see #getAncestorListeners
*/
+ @SuppressWarnings("unchecked") // Casts to (T[])
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
T[] result;
if (listenerType == AncestorListener.class) {
// AncestorListeners are handled by the AncestorNotifier
result = (T[])getAncestorListeners();