MenuShortcut
Name
MenuShortcut
Description
A MenuShortcut is used to associate a keystroke with a menu item. MenuShortcuts are constructed using their corresponding key; they are associated with menu items via MenuItem.setShortcut(MenuShortcut).
Class Definition
public class java.awt.MenuShortcut extends java.awt.Event {
// Constructors public MenuShortcut (int key);
public MenuShortcut (int key, boolean useShiftModifier); // Instance Methods public boolean equals (MenuShortcut s);
public int getKey();
public String toString();
public boolean usesShiftModifier(); // Protected Instance Methods protected String paramString();
}
Constructors
MenuShortcut
public MenuShortcut (int key)
- Parameters
-
- key
- A keycode like those returned with key press
Eventobjects.
- Description
- Constructs a
MenuShortcutobject for the givenkey.
public MenuShortcut (int key, boolean useShiftModifier)
- Parameters
-
- key
- A keycode like those returned with key press
Eventobjects. - useShiftModifier
trueif the Shift key must be used,falseotherwise.
- Description
- Constructs a
MenuShortcutobject with the given values.
Instance Methods
equals
public boolean equals (MenuShortcut s)
- Parameters
-
- s
- The
MenuShortcutto compare.
- Returns
trueifsis equal to thisMenuShortcut,falseotherwise.
getKey
public int getKey()
- Returns
- The key for this
MenuShortcut.
toString
public String toString()
- Returns
- A string representation of the
MenuShortcutobject. - Overrides
Event.toString()
usesShiftModifier
public boolean usesShiftModifier()
- Returns
trueif thisMenuShortcutmust be invoked with the Shift key pressed,falseotherwise.
Protected Instance Methods
paramString
protected String paramString()
- Returns
- String with current settings of
MenuShortcut. - Overrides
Event.paramString()- Description
- Helper method for
toString()to generate string of current settings.
See Also
Event, MenuItem