buoy.widget
Class Shortcut
public class Shortcut
extends java.lang.Object
A Shortcut represents a keyboard shortcut that can be used for activating a menu item. It consists of a
particular key that must be pressed, plus a set of modifier keys.
Every platform has a "standard" modifier key which is normally used for activating menu items. That modifier
is represented by the DEFAULT_MASK constant. In most cases, you can simply use a constructor which does not
specify modifier keys, in which case the platform-specific default modifier will be used. If you want to
add other modifier keys, you should generally combine them with the default mask. For example:
new Shortcut('X', Shortcut.SHIFT_MASK | Shortcut.DEFAULT_MASK)
will correspond to control-shift-X on Windows, and meta-shift-X on Macintosh.
Shortcut(char c) - Create a Shortcut representing a particular character, combined with the platform-specific default
modifier key.
|
Shortcut(char c, int modifiers) - Create a Shortcut representing a particular character, combined with a set of modifier keys.
|
Shortcut(int key) - Create a Shortcut representing a particular key, combined with the platform-specific default
modifier key.
|
Shortcut(int key, int modifiers) - Create a Shortcut representing a particular key, combined with a set of modifier keys.
|
char | getKeyChar() - Get the character which must be typed to activate this shortcut.
|
int | getKeyCode() - Get the key code (defined by the KeyEvent class) which must be typed to activate this shortcut.
|
KeyStroke | getKeyStroke() - Get a KeyStroke corresponding to this Shortcut.
|
int | getModifiers() - Get the set of modifier keys (a sum of the mask constants defined by this class) which must be
held down to activate this shortcut.
|
ALT_MASK
public static final int ALT_MASK
CTRL_MASK
public static final int CTRL_MASK
DEFAULT_MASK
public static final int DEFAULT_MASK
META_MASK
public static final int META_MASK
SHIFT_MASK
public static final int SHIFT_MASK
Shortcut
public Shortcut(char c)
Create a Shortcut representing a particular character, combined with the platform-specific default
modifier key.
c
- the character which must be typed to activate the shortcut
Shortcut
public Shortcut(char c,
int modifiers)
Create a Shortcut representing a particular character, combined with a set of modifier keys.
c
- the character which must be typed to activate the shortcutmodifiers
- the set of modifier keys required to activate the shortcut. This should be an ORed
combination of the mask constants defined in this class
Shortcut
public Shortcut(int key)
Create a Shortcut representing a particular key, combined with the platform-specific default
modifier key.
key
- the key code (defined by the KeyEvent class) which must be typed to activate the shortcut
Shortcut
public Shortcut(int key,
int modifiers)
Create a Shortcut representing a particular key, combined with a set of modifier keys.
key
- the key code (defined by the KeyEvent class) which must be typed to activate the shortcutmodifiers
- the set of modifier keys required to activate the shortcut. This should be an ORed
combination of the mask constants defined in this class
getKeyChar
public char getKeyChar()
Get the character which must be typed to activate this shortcut. If this Shortcut is specified by a
key code rather than a character, this returns KeyEvent.CHAR_UNDEFINED.
getKeyCode
public int getKeyCode()
Get the key code (defined by the KeyEvent class) which must be typed to activate this shortcut.
If this Shortcut is specified by a character rather than a key code, this returns KeyEvent.VK_UNDEFINED.
getKeyStroke
public KeyStroke getKeyStroke()
Get a KeyStroke corresponding to this Shortcut.
getModifiers
public int getModifiers()
Get the set of modifier keys (a sum of the mask constants defined by this class) which must be
held down to activate this shortcut.
Written by Peter Eastman.