站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 4.1.0

Mnemonics (NetBeans APIs) - NetBeans API Javadoc 4.1.0


org.openide.awt
Class Mnemonics

java.lang.Object
  extended byorg.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


Built on May 4 2005.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.