java.awt
Class MenuShortcut

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.awt.MenuShortcut
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable

public class MenuShortcut
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements Serializable sample code for java.io.Serializable definition code for java.io.Serializable

The MenuShortcutclass represents a keyboard accelerator for a MenuItem.

Menu shortcuts are created using virtual keycodes, not characters. For example, a menu shortcut for Ctrl-a (assuming that Control is the accelerator key) would be created with code like the following:

MenuShortcut ms = new MenuShortcut(KeyEvent.VK_A, false);

The accelerator key is platform-dependent and may be obtained via Toolkit.getMenuShortcutKeyMask() sample code for java.awt.Toolkit.getMenuShortcutKeyMask() definition code for java.awt.Toolkit.getMenuShortcutKeyMask() .

Since:
JDK1.1
See Also:
Serialized Form

Constructor Summary
MenuShortcut sample code for java.awt.MenuShortcut.MenuShortcut(int) definition code for java.awt.MenuShortcut.MenuShortcut(int) (int key)
          Constructs a new MenuShortcut for the specified virtual keycode.
MenuShortcut sample code for java.awt.MenuShortcut.MenuShortcut(int, boolean) definition code for java.awt.MenuShortcut.MenuShortcut(int, boolean) (int key, boolean useShiftModifier)
          Constructs a new MenuShortcut for the specified virtual keycode.
 
Method Summary
 boolean equals sample code for java.awt.MenuShortcut.equals(java.awt.MenuShortcut) definition code for java.awt.MenuShortcut.equals(java.awt.MenuShortcut) (MenuShortcut sample code for java.awt.MenuShortcut definition code for java.awt.MenuShortcut  s)
          Returns whether this MenuShortcut is the same as another: equality is defined to mean that both MenuShortcuts use the same key and both either use or don't use the SHIFT key.
 boolean equals sample code for java.awt.MenuShortcut.equals(java.lang.Object) definition code for java.awt.MenuShortcut.equals(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Returns whether this MenuShortcut is the same as another: equality is defined to mean that both MenuShortcuts use the same key and both either use or don't use the SHIFT key.
 int getKey sample code for java.awt.MenuShortcut.getKey() definition code for java.awt.MenuShortcut.getKey() ()
          Returns the raw keycode of this MenuShortcut.
 int hashCode sample code for java.awt.MenuShortcut.hashCode() definition code for java.awt.MenuShortcut.hashCode() ()
          Returns the hashcode for this MenuShortcut.
protected  String sample code for java.lang.String definition code for java.lang.String paramString sample code for java.awt.MenuShortcut.paramString() definition code for java.awt.MenuShortcut.paramString() ()
          Returns the parameter string representing the state of this MenuShortcut.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for java.awt.MenuShortcut.toString() definition code for java.awt.MenuShortcut.toString() ()
          Returns an internationalized description of the MenuShortcut.
 boolean usesShiftModifier sample code for java.awt.MenuShortcut.usesShiftModifier() definition code for java.awt.MenuShortcut.usesShiftModifier() ()
          Returns whether this MenuShortcut must be invoked using the SHIFT key.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

MenuShortcut sample code for java.awt.MenuShortcut(int) definition code for java.awt.MenuShortcut(int)

public MenuShortcut(int key)
Constructs a new MenuShortcut for the specified virtual keycode.

Parameters:
key - the raw keycode for this MenuShortcut, as would be returned in the keyCode field of a KeyEvent sample code for java.awt.event.KeyEvent definition code for java.awt.event.KeyEvent if this key were pressed.
See Also:
KeyEvent sample code for java.awt.event.KeyEvent definition code for java.awt.event.KeyEvent

MenuShortcut sample code for java.awt.MenuShortcut(int, boolean) definition code for java.awt.MenuShortcut(int, boolean)

public MenuShortcut(int key,
                    boolean useShiftModifier)
Constructs a new MenuShortcut for the specified virtual keycode.

Parameters:
key - the raw keycode for this MenuShortcut, as would be returned in the keyCode field of a KeyEvent sample code for java.awt.event.KeyEvent definition code for java.awt.event.KeyEvent if this key were pressed.
useShiftModifier - indicates whether this MenuShortcut is invoked with the SHIFT key down.
See Also:
KeyEvent sample code for java.awt.event.KeyEvent definition code for java.awt.event.KeyEvent
Method Detail

getKey sample code for java.awt.MenuShortcut.getKey() definition code for java.awt.MenuShortcut.getKey()

public int getKey()
Returns the raw keycode of this MenuShortcut.

Returns:
the raw keycode of this MenuShortcut.
Since:
JDK1.1
See Also:
KeyEvent sample code for java.awt.event.KeyEvent definition code for java.awt.event.KeyEvent

usesShiftModifier sample code for java.awt.MenuShortcut.usesShiftModifier() definition code for java.awt.MenuShortcut.usesShiftModifier()

public boolean usesShiftModifier()
Returns whether this MenuShortcut must be invoked using the SHIFT key.

Returns:
true if this MenuShortcut must be invoked using the SHIFT key, false otherwise.
Since:
JDK1.1

equals sample code for java.awt.MenuShortcut.equals(java.awt.MenuShortcut) definition code for java.awt.MenuShortcut.equals(java.awt.MenuShortcut)

public boolean equals(MenuShortcut sample code for java.awt.MenuShortcut definition code for java.awt.MenuShortcut  s)
Returns whether this MenuShortcut is the same as another: equality is defined to mean that both MenuShortcuts use the same key and both either use or don't use the SHIFT key.

Parameters:
s - the MenuShortcut to compare with this.
Returns:
true if this MenuShortcut is the same as another, false otherwise.
Since:
JDK1.1

equals sample code for java.awt.MenuShortcut.equals(java.lang.Object) definition code for java.awt.MenuShortcut.equals(java.lang.Object)

public boolean equals(Object sample code for java.lang.Object definition code for java.lang.Object  obj)
Returns whether this MenuShortcut is the same as another: equality is defined to mean that both MenuShortcuts use the same key and both either use or don't use the SHIFT key.

Overrides:
equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) in class Object sample code for java.lang.Object definition code for java.lang.Object
Parameters:
obj - the Object to compare with this.
Returns:
true if this MenuShortcut is the same as another, false otherwise.
Since:
1.2
See Also:
Object.hashCode() sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

hashCode sample code for java.awt.MenuShortcut.hashCode() definition code for java.awt.MenuShortcut.hashCode()

public int hashCode()
Returns the hashcode for this MenuShortcut.

Overrides:
hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
the hashcode for this MenuShortcut.
Since:
1.2
See Also:
Object.equals(java.lang.Object) sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

toString sample code for java.awt.MenuShortcut.toString() definition code for java.awt.MenuShortcut.toString()

public String sample code for java.lang.String definition code for java.lang.String  toString()
Returns an internationalized description of the MenuShortcut.

Overrides:
toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a string representation of this MenuShortcut.
Since:
JDK1.1

paramString sample code for java.awt.MenuShortcut.paramString() definition code for java.awt.MenuShortcut.paramString()

protected String sample code for java.lang.String definition code for java.lang.String  paramString()
Returns the parameter string representing the state of this MenuShortcut. This string is useful for debugging.

Returns:
the parameter string of this MenuShortcut.
Since:
JDK1.1