public class KeyTranslatorImpl extends Object implements KeyTranslator
KeyTranslator interface that provides facilities for
mapping key codes to action command strings for use by the KeyboardManager.| Constructor and Description |
|---|
KeyTranslatorImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
addPressCommand(int keyCode,
String command)
Adds a mapping from a key press to an action command string that will auto-repeat at a
default repeat rate.
|
void |
addPressCommand(int keyCode,
String command,
int rate)
Adds a mapping from a key press to an action command string that will auto-repeat at the
specified repeat rate.
|
void |
addPressCommand(int keyCode,
String command,
int rate,
long repeatDelay)
Adds a mapping from a key press to an action command string that will auto-repeat at the
specified repeat rate after the specified auto-repeat delay has expired.
|
void |
addReleaseCommand(int keyCode,
String command)
Adds a mapping from a key release to an action command string.
|
Iterator<String> |
enumeratePressCommands()
Returns an iterator that iterates over the available press commands.
|
Iterator<String> |
enumerateReleaseCommands()
Returns an iterator that iterates over the available release commands.
|
String |
getPressCommand(char ch)
Returns the action command string associated with a key press of the given character,
or
null if there is no associated command. |
String |
getPressCommand(int keyCode)
Returns the action command string associated with a key press of the key corresponding to
the given key code, or
null if there is no associated command. |
String |
getReleaseCommand(char ch)
Returns the action command string associated with a key release of the given character,
or
null if there is no associated command. |
String |
getReleaseCommand(int keyCode)
Returns the action command string associated with a key release of the key corresponding to
the given key code, or
null if there is no associated command. |
long |
getRepeatDelay(char ch)
Returns the delay in milliseconds before generating auto-repeated key press events for the
specified key.
|
long |
getRepeatDelay(int keyCode)
Returns the delay in milliseconds before generating auto-repeated key press events for the
specified key.
|
int |
getRepeatRate(char ch)
Returns the number of times each second that key presses are to be automatically repeated
while the key is held down, or
0 to disable auto-repeat for the key. |
int |
getRepeatRate(int keyCode)
Returns the number of times each second that key presses are to be automatically repeated
while the key is held down, or
0 to disable auto-repeat for the key. |
boolean |
hasCommand(char ch)
Returns whether there is an action command for the key corresponding to the given character
in the case of a keyTyped event corresponding to it.
|
boolean |
hasCommand(int keyCode)
Returns whether there is an action command for the key corresponding to the given keycode.
|
public void addPressCommand(int keyCode,
String command)
public void addPressCommand(int keyCode,
String command,
int rate)
rate - the number of times each second that the key press should be repeated while the
key is down, or 0 to disable auto-repeat for the key.public void addPressCommand(int keyCode,
String command,
int rate,
long repeatDelay)
rate - the number of times each second that the key press should be repeated while the
key is down; passing 0 will result in no repeating.repeatDelay - the delay in milliseconds before auto-repeating key press events will be
generated for the key.public void addReleaseCommand(int keyCode,
String command)
public boolean hasCommand(int keyCode)
KeyTranslatorhasCommand in interface KeyTranslatorpublic boolean hasCommand(char ch)
KeyTranslatorhasCommand in interface KeyTranslatorpublic String getPressCommand(int keyCode)
KeyTranslatornull if there is no associated command.getPressCommand in interface KeyTranslatorpublic String getPressCommand(char ch)
KeyTranslatornull if there is no associated command.getPressCommand in interface KeyTranslatorpublic String getReleaseCommand(int keyCode)
KeyTranslatornull if there is no associated command.getReleaseCommand in interface KeyTranslatorpublic String getReleaseCommand(char ch)
KeyTranslatornull if there is no associated command.getReleaseCommand in interface KeyTranslatorpublic int getRepeatRate(int keyCode)
KeyTranslator0 to disable auto-repeat for the key.getRepeatRate in interface KeyTranslatorpublic int getRepeatRate(char ch)
KeyTranslator0 to disable auto-repeat for the key.getRepeatRate in interface KeyTranslatorpublic long getRepeatDelay(int keyCode)
KeyTranslatorgetRepeatDelay in interface KeyTranslatorpublic long getRepeatDelay(char ch)
KeyTranslatorgetRepeatDelay in interface KeyTranslatorpublic Iterator<String> enumeratePressCommands()
KeyTranslatorenumeratePressCommands in interface KeyTranslatorpublic Iterator<String> enumerateReleaseCommands()
KeyTranslatorenumerateReleaseCommands in interface KeyTranslatorCopyright © 2015. All rights reserved.