|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.KeyboardManager
The KeyboardManager class is used to help dispatch keyboard actions for the WHEN_IN_FOCUSED_WINDOW style actions. Actions with other conditions are handled directly in JComponent. Here's a description of the symantics of how keyboard dispatching should work atleast as I understand it. KeyEvents are dispatched to the focused component. The focus manager gets first crack at processing this event. If the focus manager doesn't want it, then the JComponent calls super.processKeyEvent() this allows listeners a chance to process the event. If none of the listeners "consumes" the event then the keybindings get a shot. This is where things start to get interesting. First, KeyStokes defined with the WHEN_FOCUSED condition get a chance. If none of these want the event, then the component walks though it's parents looked for actions of type WHEN_ANCESTOR_OF_FOCUSED_COMPONENT. If no one has taken it yet, then it winds up here. We then look for components registered for WHEN_IN_FOCUSED_WINDOW events and fire to them. Note that if none of those are found then we pass the event to the menubars and let them have a crack at it. They're handled differently. Lastly, we check if we're looking at an internal frame. If we are and no one wanted the event then we move up to the InternalFrame's creator and see if anyone wants the event (and so on and so on).
InputMap
Nested Class Summary | |
(package private) class |
KeyboardManager.ComponentKeyStrokePair
This class is used to create keys for a hashtable which looks up topContainers based on component, keystroke pairs This is used to make unregistering KeyStrokes fast |
Field Summary | |
(package private) Hashtable |
componentKeyStrokeMap
Maps component/keystroke pairs to a topLevel container This is mainly used for fast unregister operations |
(package private) Hashtable |
containerMap
maps top-level containers to a sub-hashtable full of keystrokes |
(package private) static KeyboardManager |
currentManager
|
Constructor Summary | |
(package private) |
KeyboardManager()
|
Method Summary | |
(package private) void |
fireBinding(JComponent c,
KeyStroke ks,
KeyEvent e,
boolean pressed)
|
boolean |
fireKeyboardAction(KeyEvent e,
boolean pressed,
Container topAncestor)
This method is called when the focused component (and none of its ancestors) want the key event. |
static KeyboardManager |
getCurrentManager()
|
private static Container |
getTopAncestor(JComponent c)
find the top Window or Applet |
void |
registerKeyStroke(KeyStroke k,
JComponent c)
register keystrokes here which are for the WHEN_IN_FOCUSED_WINDOW case. |
void |
registerMenuBar(JMenuBar mb)
|
protected Hashtable |
registerNewTopContainer(Container topContainer)
|
static void |
setCurrentManager(KeyboardManager km)
|
void |
unregisterKeyStroke(KeyStroke ks,
JComponent c)
|
void |
unregisterMenuBar(JMenuBar mb)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
static KeyboardManager currentManager
Hashtable containerMap
Hashtable componentKeyStrokeMap
Constructor Detail |
KeyboardManager()
Method Detail |
public static KeyboardManager getCurrentManager()
public static void setCurrentManager(KeyboardManager km)
public void registerKeyStroke(KeyStroke k, JComponent c)
private static Container getTopAncestor(JComponent c)
public void unregisterKeyStroke(KeyStroke ks, JComponent c)
public boolean fireKeyboardAction(KeyEvent e, boolean pressed, Container topAncestor)
void fireBinding(JComponent c, KeyStroke ks, KeyEvent e, boolean pressed)
public void registerMenuBar(JMenuBar mb)
public void unregisterMenuBar(JMenuBar mb)
protected Hashtable registerNewTopContainer(Container topContainer)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |