988 |
{ |
{ |
989 |
VetoableChangeListener[] listeners = getVetoableChangeListeners(); |
VetoableChangeListener[] listeners = getVetoableChangeListeners(); |
990 |
|
|
991 |
PropertyChangeEvent evt = new PropertyChangeEvent(this, propertyName, oldValue, newValue); |
PropertyChangeEvent evt = |
992 |
|
new PropertyChangeEvent(this, propertyName, oldValue, newValue); |
993 |
|
|
994 |
for (int i = 0; i < listeners.length; i++) |
for (int i = 0; i < listeners.length; i++) |
995 |
listeners[i].vetoableChange(evt); |
listeners[i].vetoableChange(evt); |
2210 |
boolean pressed = e.getID() == KeyEvent.KEY_PRESSED; |
boolean pressed = e.getID() == KeyEvent.KEY_PRESSED; |
2211 |
|
|
2212 |
if (processKeyBinding(keyStroke, e, WHEN_FOCUSED, pressed)) |
if (processKeyBinding(keyStroke, e, WHEN_FOCUSED, pressed)) |
2213 |
// This is step 1 from above comment. |
{ |
2214 |
e.consume(); |
// This is step 1 from above comment. |
2215 |
|
e.consume(); |
2216 |
|
return; |
2217 |
|
} |
2218 |
else if (processKeyBinding |
else if (processKeyBinding |
2219 |
(keyStroke, e, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, pressed)) |
(keyStroke, e, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, pressed)) |
|
// This is step 2 from above comment. |
|
|
e.consume(); |
|
|
else |
|
2220 |
{ |
{ |
2221 |
// This is step 3 from above comment. |
// This is step 2 from above comment. |
2222 |
Container current = this; |
e.consume(); |
2223 |
while ((current = current.getParent()) instanceof JComponent) |
return; |
2224 |
|
} |
2225 |
|
|
2226 |
|
// This is step 3 from above comment. |
2227 |
|
Container current = getParent(); |
2228 |
|
while (current != null) |
2229 |
|
{ |
2230 |
|
// If current is a JComponent, see if it handles the event in its |
2231 |
|
// WHEN_ANCESTOR_OF_FOCUSED_COMPONENT maps. |
2232 |
|
if ((current instanceof JComponent) && |
2233 |
|
((JComponent)current).processKeyBinding |
2234 |
|
(keyStroke, e,WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, pressed)) |
2235 |
{ |
{ |
2236 |
if (((JComponent)current).processKeyBinding |
e.consume(); |
2237 |
(keyStroke, e,WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, |
return; |
2238 |
pressed)) |
} |
2239 |
{ |
|
2240 |
e.consume(); |
// Stop when we've tried a top-level container and it didn't handle it |
2241 |
break; |
if (current instanceof Window || current instanceof Applet) |
2242 |
} |
break; |
2243 |
if (current instanceof Window || current instanceof Applet |
|
2244 |
|| current instanceof JInternalFrame) |
// Move up the hierarchy |
2245 |
break; |
current = current.getParent(); |
|
} |
|
|
if (e.isConsumed()) |
|
|
return; |
|
|
|
|
|
// This is step 4 from above comment. |
|
|
if (KeyboardManager.getManager().processKeyStroke(this, keyStroke, e)) |
|
|
e.consume(); |
|
2246 |
} |
} |
2247 |
|
|
2248 |
|
// Current being null means the JComponent does not currently have a |
2249 |
|
// top-level ancestor, in which case we don't need to check |
2250 |
|
// WHEN_IN_FOCUSED_WINDOW bindings. |
2251 |
|
if (current == null || e.isConsumed()) |
2252 |
|
return; |
2253 |
|
|
2254 |
|
// This is step 4 from above comment. KeyboardManager maintains mappings |
2255 |
|
// related to WHEN_IN_FOCUSED_WINDOW bindings so that we don't have to |
2256 |
|
// traverse the containment hierarchy each time. |
2257 |
|
if (KeyboardManager.getManager().processKeyStroke(current, keyStroke, e)) |
2258 |
|
e.consume(); |
2259 |
} |
} |
2260 |
|
|
2261 |
protected boolean processKeyBinding(KeyStroke ks, |
protected boolean processKeyBinding(KeyStroke ks, |
3366 |
// delete all the old bindings for the component and then register |
// delete all the old bindings for the component and then register |
3367 |
// the current bindings. |
// the current bindings. |
3368 |
km.clearBindingsForComp(changed.getComponent()); |
km.clearBindingsForComp(changed.getComponent()); |
3369 |
km.registerEntireMap((ComponentInputMap) getInputMap(WHEN_IN_FOCUSED_WINDOW)); |
km.registerEntireMap((ComponentInputMap) |
3370 |
|
getInputMap(WHEN_IN_FOCUSED_WINDOW)); |
3371 |
} |
} |
3372 |
} |
} |