< prev index next >
src/java.desktop/share/classes/java/awt/MenuShortcut.java
Print this page
*** 25,55 ****
package java.awt;
import java.awt.event.KeyEvent;
/**
! * The <code>MenuShortcut</code>class represents a keyboard accelerator
* for a MenuItem.
* <p>
* 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:
* <p>
! * <code>MenuShortcut ms = new MenuShortcut(KeyEvent.VK_A, false);</code>
* <p> or alternatively
* <p>
! * <code>MenuShortcut ms = new MenuShortcut(KeyEvent.getExtendedKeyCodeForChar('A'), false);</code>
* <p>
* Menu shortcuts may also be constructed for a wider set of keycodes
! * using the <code>java.awt.event.KeyEvent.getExtendedKeyCodeForChar</code> call.
* For example, a menu shortcut for "Ctrl+cyrillic ef" is created by
* <p>
* <code>MenuShortcut ms = new MenuShortcut(KeyEvent.getExtendedKeyCodeForChar('\u0444'), false);</code>
* <p>
! * Note that shortcuts created with a keycode or an extended keycode defined as a constant in <code>KeyEvent</code>
* work regardless of the current keyboard layout. However, a shortcut made of
! * an extended keycode not listed in <code>KeyEvent</code>
* only work if the current keyboard layout produces a corresponding letter.
* <p>
* The accelerator key is platform-dependent and may be obtained
* via {@link Toolkit#getMenuShortcutKeyMask}.
*
--- 25,55 ----
package java.awt;
import java.awt.event.KeyEvent;
/**
! * The {@code MenuShortcut} class represents a keyboard accelerator
* for a MenuItem.
* <p>
* 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:
* <p>
! * {@code MenuShortcut ms = new MenuShortcut(KeyEvent.VK_A, false);}
* <p> or alternatively
* <p>
! * {@code MenuShortcut ms = new MenuShortcut(KeyEvent.getExtendedKeyCodeForChar('A'), false);}
* <p>
* Menu shortcuts may also be constructed for a wider set of keycodes
! * using the {@code java.awt.event.KeyEvent.getExtendedKeyCodeForChar} call.
* For example, a menu shortcut for "Ctrl+cyrillic ef" is created by
* <p>
* <code>MenuShortcut ms = new MenuShortcut(KeyEvent.getExtendedKeyCodeForChar('\u0444'), false);</code>
* <p>
! * Note that shortcuts created with a keycode or an extended keycode defined as a constant in {@code KeyEvent}
* work regardless of the current keyboard layout. However, a shortcut made of
! * an extended keycode not listed in {@code KeyEvent}
* only work if the current keyboard layout produces a corresponding letter.
* <p>
* The accelerator key is platform-dependent and may be obtained
* via {@link Toolkit#getMenuShortcutKeyMask}.
*
*** 126,137 ****
return key;
}
/**
* Returns whether this MenuShortcut must be invoked using the SHIFT key.
! * @return <code>true</code> if this MenuShortcut must be invoked using the
! * SHIFT key, <code>false</code> otherwise.
* @since 1.1
*/
public boolean usesShiftModifier() {
return usesShift;
}
--- 126,137 ----
return key;
}
/**
* Returns whether this MenuShortcut must be invoked using the SHIFT key.
! * @return {@code true} if this MenuShortcut must be invoked using the
! * SHIFT key, {@code false} otherwise.
* @since 1.1
*/
public boolean usesShiftModifier() {
return usesShift;
}
*** 139,150 ****
/**
* 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.
* @param s the MenuShortcut to compare with this.
! * @return <code>true</code> if this MenuShortcut is the same as another,
! * <code>false</code> otherwise.
* @since 1.1
*/
public boolean equals(MenuShortcut s) {
return (s != null && (s.getKey() == key) &&
(s.usesShiftModifier() == usesShift));
--- 139,150 ----
/**
* 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.
* @param s the MenuShortcut to compare with this.
! * @return {@code true} if this MenuShortcut is the same as another,
! * {@code false} otherwise.
* @since 1.1
*/
public boolean equals(MenuShortcut s) {
return (s != null && (s.getKey() == key) &&
(s.usesShiftModifier() == usesShift));
*** 153,164 ****
/**
* 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.
* @param obj the Object to compare with this.
! * @return <code>true</code> if this MenuShortcut is the same as another,
! * <code>false</code> otherwise.
* @since 1.2
*/
public boolean equals(Object obj) {
if (obj instanceof MenuShortcut) {
return equals( (MenuShortcut) obj );
--- 153,164 ----
/**
* 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.
* @param obj the Object to compare with this.
! * @return {@code true} if this MenuShortcut is the same as another,
! * {@code false} otherwise.
* @since 1.2
*/
public boolean equals(Object obj) {
if (obj instanceof MenuShortcut) {
return equals( (MenuShortcut) obj );
< prev index next >