public class KeyEventTranslator
extends java.lang.Object
KeyEventWorkaround, hides some
warts in the AWT key event API.| Modifier and Type | Class and Description |
|---|---|
static class |
KeyEventTranslator.Key |
| Modifier and Type | Field and Description |
|---|---|
protected static boolean |
lastKeyPressAccepted |
protected static java.awt.event.KeyEvent |
lastKeyPressEvent |
| Constructor and Description |
|---|
KeyEventTranslator() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addTranslation(KeyEventTranslator.Key key1,
KeyEventTranslator.Key key2)
Adds a keyboard translation.
|
static java.lang.String |
getModifierString(java.awt.event.InputEvent evt)
Returns a string containing symbolic modifier names set in the
specified event.
|
static char |
getSymbolicModifierName(int mod)
Returns a the symbolic modifier name for the specified Java modifier
flag.
|
static java.lang.String |
modifiersToString(int mods) |
static KeyEventTranslator.Key |
parseKey(java.lang.String keyStroke)
Converts a string to a keystroke.
|
static javax.swing.KeyStroke |
parseKeyStroke(java.lang.String shortcut)
Converts a string to a Swing KeyStroke.
|
static void |
setModifierMapping(int c,
int a,
int m,
int s)
Changes the mapping between symbolic modifier key names
(
C, A, M, S) and
Java modifier flags. |
static KeyEventTranslator.Key |
translateKeyEvent(java.awt.event.KeyEvent evt)
Pass this an event from
KeyEventWorkaround.processKeyEvent(java.awt.event.KeyEvent). |
protected static java.awt.event.KeyEvent lastKeyPressEvent
protected static boolean lastKeyPressAccepted
public static void addTranslation(KeyEventTranslator.Key key1, KeyEventTranslator.Key key2)
key1 - Translate this keykey2 - Into this keypublic static KeyEventTranslator.Key translateKeyEvent(java.awt.event.KeyEvent evt)
KeyEventWorkaround.processKeyEvent(java.awt.event.KeyEvent).evt - the KeyEvent to translatepublic static KeyEventTranslator.Key parseKey(java.lang.String keyStroke)
KeyEvent class, without
the VK_ prefix.keyStroke - A string description of the key strokepublic static javax.swing.KeyStroke parseKeyStroke(java.lang.String shortcut)
KeyEvent class, without
the VK_ prefix. Returns null if the string corresponds
to multiple KeyStrokes (e.g., "C+e C+COMMA").shortcut - A string description of the key strokepublic static void setModifierMapping(int c,
int a,
int m,
int s)
C, A, M, S) and
Java modifier flags.
You can map more than one Java modifier to a symobolic modifier, for
example :
setModifierMapping(
InputEvent.CTRL_MASK,
InputEvent.ALT_MASK | InputEvent.META_MASK,
0,
InputEvent.SHIFT_MASK);
c - The modifier(s) to map the C modifier toa - The modifier(s) to map the A modifier tom - The modifier(s) to map the M modifier tos - The modifier(s) to map the S modifier topublic static char getSymbolicModifierName(int mod)
mod - A modifier constant from InputEventpublic static java.lang.String modifiersToString(int mods)
public static java.lang.String getModifierString(java.awt.event.InputEvent evt)
evt - The event