com.tensegrity.generic.util
Class KeyStroke

java.lang.Object
  extended bycom.tensegrity.generic.util.KeyStroke
Direct Known Subclasses:
SwtKeyStroke

public class KeyStroke
extends java.lang.Object

Class KeyStroke represents a key action (after pressing or releasing a keyboard button) on the keyboard. A KeyStroke can also specify the modifiers alt, shift, control, meta or any combination of the four simultaneously pressed. Instances are immutable.

KeyStroke instances are used to define high-level action events and can automatically initiate actions on the components with which they are registered.

Version:
$Id: KeyStroke.java,v 1.13 2005/11/18 11:34:51 KevinCVS Exp $
Author:
MichaelKegel, BurkhardWick

Field Summary
static int ALT_GRAPH_MASK
          mask for the AltGr-key
static KeyStroke ALT_KEY
          keystroke representing the Alt-key
static int ALT_KEY_CODE
          Key code for the alt key
static int ALT_MASK
          mask for the Alt-key
static KeyStroke CTRL_KEY
          keystroke representing the Ctrl-key
static int CTRL_KEY_CODE
          Key code for the control key
static int CTRL_MASK
          mask for the Ctrl-key
static int META_MASK
          mask for the Meta-key
static int NO_MASK
          mask, if no modifying key is pressed
static KeyStroke SHIFT_KEY
          keystroke representing the Shift-key
static int SHIFT_KEY_CODE
          Key code for the shift key
static int SHIFT_MASK
          mask for the Shift-key
 
Constructor Summary
KeyStroke(char keyChar, int keyCode, int modifiers)
          Constructor for a KeyStroke.
KeyStroke(char keyChar, int keyCode, int modifiers, boolean onKeyRelease)
          Constructor for a KeyStroke.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 char getChar()
          Returns the character specified for this KeyStroke instance.
 int getCode()
          Returns the keyCode specified for this KeyStroke instance.
 int getModifiers()
          Returns the modifiers specified for this KeyStroke instance.
 int hashCode()
           
 boolean isOnKeyRelease()
          Returns true, if this keystroke should trigger the action if the key is released and not if the key is pressed
 java.lang.String toString()
           
static java.lang.String toStringModifiers(int modifiers)
          Returns a textual representation for the given modifiers.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_MASK

public static final int NO_MASK
mask, if no modifying key is pressed

See Also:
Constant Field Values

SHIFT_MASK

public static final int SHIFT_MASK
mask for the Shift-key

See Also:
Constant Field Values

CTRL_MASK

public static final int CTRL_MASK
mask for the Ctrl-key

See Also:
Constant Field Values

META_MASK

public static final int META_MASK
mask for the Meta-key

See Also:
Constant Field Values

ALT_MASK

public static final int ALT_MASK
mask for the Alt-key

See Also:
Constant Field Values

ALT_GRAPH_MASK

public static final int ALT_GRAPH_MASK
mask for the AltGr-key

See Also:
Constant Field Values

SHIFT_KEY_CODE

public static final int SHIFT_KEY_CODE
Key code for the shift key

See Also:
Constant Field Values

ALT_KEY_CODE

public static final int ALT_KEY_CODE
Key code for the alt key

See Also:
Constant Field Values

CTRL_KEY_CODE

public static final int CTRL_KEY_CODE
Key code for the control key

See Also:
Constant Field Values

SHIFT_KEY

public static final KeyStroke SHIFT_KEY
keystroke representing the Shift-key


CTRL_KEY

public static final KeyStroke CTRL_KEY
keystroke representing the Ctrl-key


ALT_KEY

public static final KeyStroke ALT_KEY
keystroke representing the Alt-key

Constructor Detail

KeyStroke

public KeyStroke(char keyChar,
                 int keyCode,
                 int modifiers)
Constructor for a KeyStroke.

Parameters:
keyChar - the char of the key.
keyCode - an int specifying the numeric code for a key.
modifiers - an int specifying any combination of the key modifiers. Have a look at the corresponding constants.

KeyStroke

public KeyStroke(char keyChar,
                 int keyCode,
                 int modifiers,
                 boolean onKeyRelease)
Constructor for a KeyStroke.

Parameters:
keyChar - the char of the key.
keyCode - an int specifying the numeric code for a key.
modifiers - an int specifying any combination of the key modifiers. Have a look at the corresponding constants.
onKeyRelease - A flag specifying whether this keystroke should trigger an action on pressed or released event
Method Detail

getChar

public final char getChar()
Returns the character specified for this KeyStroke instance.

Returns:
the char value of this KeyStroke.

getCode

public final int getCode()
Returns the keyCode specified for this KeyStroke instance.

Returns:
the int value for the keyCode.

getModifiers

public final int getModifiers()
Returns the modifiers specified for this KeyStroke instance.

Returns:
the int value for modifiers.

toStringModifiers

public static final java.lang.String toStringModifiers(int modifiers)
Returns a textual representation for the given modifiers.

Parameters:
modifiers - an int specifying key modifiers.
Returns:
a corresponding textual representation.

equals

public final boolean equals(java.lang.Object o)

hashCode

public int hashCode()

toString

public final java.lang.String toString()

isOnKeyRelease

public boolean isOnKeyRelease()
Returns true, if this keystroke should trigger the action if the key is released and not if the key is pressed

Returns:
true, if this keystroke should trigger the action if the key is released


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.