public class KeyStrokeAdapter
extends java.lang.Object
implements java.awt.event.KeyListener
Constructor and Description |
---|
KeyStrokeAdapter() |
Modifier and Type | Method and Description |
---|---|
static javax.swing.KeyStroke |
getDefaultKeyStroke(java.awt.event.KeyEvent event) |
static javax.swing.KeyStroke |
getKeyStroke(java.awt.event.KeyEvent event,
boolean extended) |
static javax.swing.KeyStroke |
getKeyStroke(java.lang.String string)
Parses a string and returns the corresponding key stroke.
|
void |
keyPressed(java.awt.event.KeyEvent event) |
protected boolean |
keyPressed(javax.swing.KeyStroke stroke) |
void |
keyReleased(java.awt.event.KeyEvent event) |
protected boolean |
keyReleased(javax.swing.KeyStroke stroke) |
void |
keyTyped(java.awt.event.KeyEvent event) |
protected boolean |
keyTyped(javax.swing.KeyStroke stroke) |
static java.lang.String |
toString(javax.swing.KeyStroke stroke)
Returns a string that represents the specified key stroke.
|
public void keyTyped(java.awt.event.KeyEvent event)
keyTyped
in interface java.awt.event.KeyListener
protected boolean keyTyped(javax.swing.KeyStroke stroke)
public void keyPressed(java.awt.event.KeyEvent event)
keyPressed
in interface java.awt.event.KeyListener
protected boolean keyPressed(javax.swing.KeyStroke stroke)
public void keyReleased(java.awt.event.KeyEvent event)
keyReleased
in interface java.awt.event.KeyListener
protected boolean keyReleased(javax.swing.KeyStroke stroke)
public static javax.swing.KeyStroke getDefaultKeyStroke(java.awt.event.KeyEvent event)
event
- the specified key event to processnull
if it is not applicableKeyStroke.getKeyStrokeForEvent(KeyEvent)
public static javax.swing.KeyStroke getKeyStroke(java.awt.event.KeyEvent event, boolean extended)
event
- the specified key event to processextended
- true
if extended key code should be usednull
if it is not applicableJComponent.processKeyBindings(KeyEvent, boolean)
public static javax.swing.KeyStroke getKeyStroke(java.lang.String string)
<modifiers>* (<typedID> | <pressedReleasedID>)where
modifiers := shift | ctrl | control | meta | alt | altGr | altGraph typedID := typed <char> pressedReleasedID := (pressed | released) keyIf
typed
, pressed
or released
is not specified, pressed
is assumed.
The char
is a string of length 1 giving Unicode character.
The key
is a virtual key name or an integer that represents a key code.
Note that the virtual key name is a second part of a name
of the corresponding field defined in the KeyEvent
class.
This method has two differences from the KeyStroke.getKeyStroke(String)
method.
First, it does not throw an exception if the specified string cannot be parsed.
Second, it supports an integer representation of a key code
if the corresponding virtual key is not specified in the KeyEvent
class.
This method returns null
if the specified string is null
or if it cannot be parsed.
The error message is logged without throwing an exception.string
- the specified string to parse as described abovepublic static java.lang.String toString(javax.swing.KeyStroke stroke)
getKeyStroke(String)
method to produce
a key stroke equal to the specified key stroke.
This method has two differences from the AWTKeyStroke.toString()
method.
First, the resulting string does not contain the "pressed" keyword.
Second, the resulting string contains a hexadecimal integer instead of null
if the corresponding virtual key is not specified in the KeyEvent
class.
This method returns null
if the specified key stroke is null
or
if its keyCode
and keyChar
both are undefined.stroke
- the specified key stroke to process