public class KeyDispatcher extends Object implements KeyEventDispatcher, AncestorListener, WindowFocusListener
A JTextComponent may registered as a "chat grabber" via
pushChatGrabber(javax.swing.text.JTextComponent) so as to capture typed chat characters
regardless of which component currently has the focus.
Components may also register as global KeyListeners via
addGlobalKeyListener(java.awt.event.KeyListener) to always be notified of key press and
release events for all keys.
| Constructor and Description |
|---|
KeyDispatcher(Window window)
Constructs a key dispatcher.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addGlobalKeyListener(KeyListener listener)
Adds the key listener to receive all key events at all times.
|
void |
ancestorAdded(AncestorEvent ae) |
void |
ancestorMoved(AncestorEvent ae) |
void |
ancestorRemoved(AncestorEvent ae) |
boolean |
dispatchKeyEvent(KeyEvent e) |
void |
pushChatGrabber(JTextComponent comp)
Makes the specified component the new grabber of key typed events
that look like they're chat-related per
isChatCharacter(char). |
void |
removeChatGrabber(JTextComponent comp)
Removes the specified component from the list of chat grabbers so
that it will no longer be notified of chat-like key events.
|
void |
removeGlobalKeyListener(KeyListener listener)
Removes the specified global key listener.
|
void |
shutdown()
Shuts down the key dispatcher.
|
void |
windowGainedFocus(WindowEvent e) |
void |
windowLostFocus(WindowEvent e) |
public KeyDispatcher(Window window)
public void shutdown()
public void pushChatGrabber(JTextComponent comp)
isChatCharacter(char).public void removeChatGrabber(JTextComponent comp)
public void addGlobalKeyListener(KeyListener listener)
public void removeGlobalKeyListener(KeyListener listener)
public boolean dispatchKeyEvent(KeyEvent e)
dispatchKeyEvent in interface KeyEventDispatcherpublic void windowGainedFocus(WindowEvent e)
windowGainedFocus in interface WindowFocusListenerpublic void windowLostFocus(WindowEvent e)
windowLostFocus in interface WindowFocusListenerpublic void ancestorAdded(AncestorEvent ae)
ancestorAdded in interface AncestorListenerpublic void ancestorMoved(AncestorEvent ae)
ancestorMoved in interface AncestorListenerpublic void ancestorRemoved(AncestorEvent ae)
ancestorRemoved in interface AncestorListenerCopyright © 2015. All rights reserved.