2828 |
*/ |
*/ |
2829 |
public void addNotify() |
public void addNotify() |
2830 |
{ |
{ |
2831 |
|
// Register the WHEN_IN_FOCUSED_WINDOW keyboard bindings |
2832 |
|
// Note that here we unregister all bindings associated with |
2833 |
|
// this component and then re-register them. This may be more than |
2834 |
|
// necessary if the top-level ancestor hasn't changed. Should |
2835 |
|
// maybe improve this. |
2836 |
|
KeyboardManager km = KeyboardManager.getManager(); |
2837 |
|
km.clearBindingsForComp(this); |
2838 |
|
km.registerEntireMap((ComponentInputMap) |
2839 |
|
this.getInputMap(WHEN_IN_FOCUSED_WINDOW)); |
2840 |
super.addNotify(); |
super.addNotify(); |
2841 |
|
|
|
// let parents inherit the keybord mapping |
|
|
InputMap input = getInputMap(); |
|
|
ActionMap actions = getActionMap(); |
|
|
|
|
|
Container parent = getParent(); |
|
|
while ((parent != null) && (parent instanceof JComponent)) |
|
|
{ |
|
|
JComponent jParent = (JComponent) parent; |
|
|
InputMap parentInput = jParent.getInputMap(); |
|
|
ActionMap parentAction = jParent.getActionMap(); |
|
|
|
|
|
KeyStroke[] ikeys = input.keys(); |
|
|
for (int i = 0; i < ikeys.length; i++) |
|
|
{ |
|
|
Object o = input.get(ikeys[i]); |
|
|
parentInput.put(ikeys[i], o); |
|
|
} |
|
|
|
|
|
Object[] akeys = actions.keys(); |
|
|
for (int i = 0; i < akeys.length; i++) |
|
|
{ |
|
|
Action a = actions.get(akeys[i]); |
|
|
parentAction.put(akeys[i], a); |
|
|
} |
|
|
|
|
|
parent = jParent.getParent(); |
|
|
} |
|
|
|
|
2842 |
// Notify AncestorListeners. |
// Notify AncestorListeners. |
2843 |
fireAncestorEvent(this, AncestorEvent.ANCESTOR_ADDED); |
fireAncestorEvent(this, AncestorEvent.ANCESTOR_ADDED); |
2844 |
|
|
2845 |
// fire property change event for 'ancestor' |
// fire property change event for 'ancestor' |
2846 |
firePropertyChange("ancestor", null, parent); |
firePropertyChange("ancestor", null, getParent()); |
2847 |
} |
} |
2848 |
|
|
2849 |
/** |
/** |