930 |
list.removeMouseMotionListener(mouseInputListener); |
list.removeMouseMotionListener(mouseInputListener); |
931 |
list.removePropertyChangeListener(propertyChangeListener); |
list.removePropertyChangeListener(propertyChangeListener); |
932 |
} |
} |
|
|
|
|
private int convertModifiers(int mod) |
|
|
{ |
|
|
if ((mod & KeyEvent.SHIFT_DOWN_MASK) != 0) |
|
|
{ |
|
|
mod |= KeyEvent.SHIFT_MASK; |
|
|
mod &= ~KeyEvent.SHIFT_DOWN_MASK; |
|
|
} |
|
|
if ((mod & KeyEvent.CTRL_DOWN_MASK) != 0) |
|
|
{ |
|
|
mod |= KeyEvent.CTRL_MASK; |
|
|
mod &= ~KeyEvent.CTRL_DOWN_MASK; |
|
|
} |
|
|
if ((mod & KeyEvent.META_DOWN_MASK) != 0) |
|
|
{ |
|
|
mod |= KeyEvent.META_MASK; |
|
|
mod &= ~KeyEvent.META_DOWN_MASK; |
|
|
} |
|
|
if ((mod & KeyEvent.ALT_DOWN_MASK) != 0) |
|
|
{ |
|
|
mod |= KeyEvent.ALT_MASK; |
|
|
mod &= ~KeyEvent.ALT_DOWN_MASK; |
|
|
} |
|
|
if ((mod & KeyEvent.ALT_GRAPH_DOWN_MASK) != 0) |
|
|
{ |
|
|
mod |= KeyEvent.ALT_GRAPH_MASK; |
|
|
mod &= ~KeyEvent.ALT_GRAPH_DOWN_MASK; |
|
|
} |
|
|
return mod; |
|
|
} |
|
933 |
|
|
934 |
/** |
/** |
935 |
* Installs keyboard actions for this UI in the {@link JList}. |
* Installs keyboard actions for this UI in the {@link JList}. |
944 |
action = new ListAction(); |
action = new ListAction(); |
945 |
Object keys[] = focusInputMap.allKeys(); |
Object keys[] = focusInputMap.allKeys(); |
946 |
// Register key bindings in the UI InputMap-ActionMap pair |
// Register key bindings in the UI InputMap-ActionMap pair |
|
// Note that we register key bindings with both the old and new modifier |
|
|
// masks: InputEvent.SHIFT_MASK and InputEvent.SHIFT_DOWN_MASK and so on. |
|
947 |
for (int i = 0; i < keys.length; i++) |
for (int i = 0; i < keys.length; i++) |
948 |
{ |
{ |
949 |
parentInputMap.put(KeyStroke.getKeyStroke |
KeyStroke stroke = (KeyStroke)keys[i]; |
950 |
(((KeyStroke)keys[i]).getKeyCode(), convertModifiers |
String actionString = (String) focusInputMap.get(stroke); |
951 |
(((KeyStroke)keys[i]).getModifiers())), |
parentInputMap.put(KeyStroke.getKeyStroke(stroke.getKeyCode(), |
952 |
(String)focusInputMap.get((KeyStroke)keys[i])); |
stroke.getModifiers()), |
953 |
|
actionString); |
|
parentInputMap.put(KeyStroke.getKeyStroke |
|
|
(((KeyStroke)keys[i]).getKeyCode(), |
|
|
((KeyStroke)keys[i]).getModifiers()), |
|
|
(String)focusInputMap.get((KeyStroke)keys[i])); |
|
954 |
|
|
955 |
parentActionMap.put |
parentActionMap.put (actionString, |
956 |
((String)focusInputMap.get((KeyStroke)keys[i]), new ActionListenerProxy |
new ActionListenerProxy(action, actionString)); |
|
(action, (String)focusInputMap.get((KeyStroke)keys[i]))); |
|
957 |
} |
} |
958 |
|
// Register the new InputMap-ActionMap as the parents of the list's |
959 |
|
// InputMap and ActionMap |
960 |
parentInputMap.setParent(list.getInputMap().getParent()); |
parentInputMap.setParent(list.getInputMap().getParent()); |
961 |
parentActionMap.setParent(list.getActionMap().getParent()); |
parentActionMap.setParent(list.getActionMap().getParent()); |
962 |
list.getInputMap().setParent(parentInputMap); |
list.getInputMap().setParent(parentInputMap); |