Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| org.openide.awt 6.7.22
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.openide.awt
Class Mnemonics

    java.lang.Object
      org.openide.awt.Mnemonics

    public final class Mnemonics

extends Object

Support class for setting button, menu, and label text strings with mnemonics.

Since:
  3.37
See Also:
  Issue #26640

Method Summary
`static int` | `findMnemonicAmpersand(String text)` Searches for an ampersand in a string which indicates a mnemonic.
`static void` | `setLocalizedText(AbstractButton item, String text)` Sets the text for a menu item or other subclass of AbstractButton.
`static void` | `setLocalizedText(JLabel item, String text)` Sets the text for the label or other subclass of JLabel.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### setLocalizedText

    public static void setLocalizedText(AbstractButton item,
                                        String text)

  Sets the text for a menu item or other subclass of AbstractButton.

  Examples:

  Input String | View under JDK 1.3 | View under JDK 1.4 or later
  --- | --- | ---
  `Save &As``` | Save As | Save As
  `Rock & Roll``` | Rock & Roll | Rock & Roll
  `Drag & &Drop``` | Drag & Drop | Drag & Drop
  `&Файл` | Файл (F) | Файл

  Parameters:
    `item` - a button whose text will be changed
    `text` - new label

### setLocalizedText

    public static void setLocalizedText(JLabel item,
                                        String text)

  Sets the text for the label or other subclass of JLabel. For details see `setLocalizedText(AbstractButton, String)`.

  Parameters:
    `item` - a label whose text will be set
    `text` - new label

### findMnemonicAmpersand

    public static int findMnemonicAmpersand(String text)

  Searches for an ampersand in a string which indicates a mnemonic. Recognizes the following cases:
  - "Drag & Drop", "Ampersand ('&')" - don't have mnemonic ampersand. "&" is not found before " " (space), or if enclosed in "'" (single quotation marks).
  - "&File", "Save &As..." - do have mnemonic ampersand.
  - "Rock & Ro&ll", "Underline the '&' &character" - also do have mnemonic ampersand, but the second one.

  Parameters:
    `text` - text to search
  Returns:
    the position of mnemonic ampersand in text, or -1 if there is none

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| org.openide.awt 6.7.22
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Built on December 7 2006. | Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.