|
Key Bindings
An Introduction with Examples in Java |
|
Prof. David Bernstein
|
| Computer Science Department |
| bernstdh@jmu.edu |
JComponent objects to respond
to the keyboardAbstractButton,
JLabel, and JTabbedPane)JMenutItem)
Action objects)
so are more maintainableJComponent to have the
focusJComponent Objects
ActionMap Object:
Action to
a String that has been mapped/bound to
a KeyStroke)InputMap Objects:
JComponent has the focusJComponent contains (or is)
the component that has the focusJComponent is in the window
that has the focus
InputMap objects is searched
for a matching bindingActionMap is searched for
a matching Action
Action is enabled
it's actionPerformed() method is called
(and the process is terminated), otherwise the search
continuesInputMap Search Order:
WHEN_FOCUSED mapWHEN_ANCESTOR_OF_FOCUSED_COMPONENT mapWHEN_ANCESTOR_OF_FOCUSED_COMPONENT maps
of enabled containers (in order)WHEN_IN_FOCUSED_WINDOW maps (in no
particular order)