public class KeyboardManager extends Object implements KeyEventDispatcher, AncestorListener, WindowFocusListener
Controller hierarchy. It allows specifying the
key repeat rate, and will begin repeating a key immediately after it is held down rather than
depending on the system-specific key repeat delay/rate.| Modifier and Type | Class and Description |
|---|---|
static interface |
KeyboardManager.KeyObserver
An interface to be implemented by those that care to be notified whenever an event (either a
key press or a key release) occurs for any key while the keyboard manager is active.
|
| Constructor and Description |
|---|
KeyboardManager()
Constructs a keyboard manager that is initially disabled.
|
| Modifier and Type | Method and Description |
|---|---|
void |
ancestorAdded(AncestorEvent e) |
void |
ancestorMoved(AncestorEvent e) |
void |
ancestorRemoved(AncestorEvent e) |
boolean |
dispatchKeyEvent(KeyEvent e) |
void |
registerKeyObserver(KeyboardManager.KeyObserver obs)
Registers a key observer that will be notified of all key events while the keyboard manager
is active.
|
void |
releaseAllKeys()
Releases all keys and ceases any hot repeating action that may be going on.
|
void |
removeKeyObserver(KeyboardManager.KeyObserver obs)
Removes the supplied key observer from the list of observers to be notified of all key
events while the keyboard manager is active.
|
void |
reset()
Resets the keyboard manager, clearing any target and key translator in use and disabling the
keyboard manager if it is currently active.
|
void |
setEnabled(boolean enabled)
Sets whether the keyboard manager processes keyboard input.
|
void |
setRepeatDelay(long delay)
Sets the expected delay in milliseconds between each key press/release event the keyboard
manager should expect to receive while a key is repeating.
|
void |
setTarget(JComponent target,
KeyTranslator xlate)
Initializes the keyboard manager with the supplied target component and key translator and
disables the keyboard manager if it is currently active.
|
void |
windowGainedFocus(WindowEvent e) |
void |
windowLostFocus(WindowEvent e) |
public KeyboardManager()
setTarget(javax.swing.JComponent, com.threerings.util.KeyTranslator).public void reset()
public void setTarget(JComponent target, KeyTranslator xlate)
target - the component whose keyboard events are to be observed.xlate - the key translator used to map keyboard events to controller action commands.public void registerKeyObserver(KeyboardManager.KeyObserver obs)
public void removeKeyObserver(KeyboardManager.KeyObserver obs)
public void setEnabled(boolean enabled)
public void setRepeatDelay(long delay)
public void releaseAllKeys()
public boolean dispatchKeyEvent(KeyEvent e)
dispatchKeyEvent in interface KeyEventDispatcherpublic void ancestorAdded(AncestorEvent e)
ancestorAdded in interface AncestorListenerpublic void ancestorMoved(AncestorEvent e)
ancestorMoved in interface AncestorListenerpublic void ancestorRemoved(AncestorEvent e)
ancestorRemoved in interface AncestorListenerpublic void windowGainedFocus(WindowEvent e)
windowGainedFocus in interface WindowFocusListenerpublic void windowLostFocus(WindowEvent e)
windowLostFocus in interface WindowFocusListenerCopyright © 2015. All rights reserved.