|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object abbot.editor.widgets.Mnemonic
public class Mnemonic
Provide access to mnemonics appropriate for the current platform and
locale. Encapsulates displayed text, a KeyEvent.VK_ constant, and a
displayed mnemonic index. All instances are obtained through the factory
method, getMnemonic(String)
.
KeyEvent
,
AbstractButton.setMnemonic(int)
,
AbstractButton.setDisplayedMnemonicIndex(int)
,
JLabel.setDisplayedMnemonic(int)
,
JLabel.setDisplayedMnemonicIndex(int)
,
Action.MNEMONIC_KEY
Field Summary | |
---|---|
int |
index
The index to use as an argument to AbstractButton.setDisplayedMnemonicIndex(int) . |
int |
keycode
The keycode to use as an argument to AbstractButton.setMnemonic(int) . |
String |
text
The unencoded text. |
Method Summary | |
---|---|
static Mnemonic |
getMnemonic(String input)
Create a Mnemonic instance with the mnemonic information from the given encoded String. |
static void |
setDisplayedMnemonicIndex(Component c,
int index)
Set the displayed mnemonic index, if doing so is supported. |
void |
setMnemonic(AbstractButton button)
Apply this mnemonic to the given AbstractButton. |
void |
setMnemonic(Action action)
Apply this mnemonic to the given Action. |
void |
setMnemonic(JLabel label)
Apply this mnemonic to the given JLabel. |
void |
setMnemonic(JTabbedPane tabbedPane,
int tabIndex)
Apply this mnemonic to the given JLabel. |
String |
toString()
|
static boolean |
useMnemonics()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public String text
public int keycode
AbstractButton.setMnemonic(int)
. Returns
KeyEvent.VK_UNDEFINED if no mnemonic was found.
public int index
AbstractButton.setDisplayedMnemonicIndex(int)
. Returns
-1 if the default value should be used.
Method Detail |
---|
public static void setDisplayedMnemonicIndex(Component c, int index)
public String toString()
toString
in class Object
public void setMnemonic(AbstractButton button)
public void setMnemonic(JLabel label)
public void setMnemonic(JTabbedPane tabbedPane, int tabIndex)
public void setMnemonic(Action action)
public static Mnemonic getMnemonic(String input)
Mnemonics may be encoded as follows:
Original Text | Visible Text | Mnemonic |
&File | File | VK_F |
Save &As... | Save As... | VK_A second instance |
Me&&&You | Me&You | VK_Y ambiguous ampersands must be escaped |
Sugar & Spice | Sugar & Spice | None ampersand is unambiguous, whitespace is not allowed as a mnemonic |
Swing restricts mnemonics to available KeyEvent VK_ constants, so there must exist a mapping between text characters and said constants. If the obvious mappings (A-Z, a-z, 0-9) don't hold, lookup falls back to other methods. Whitespace, quotes, and ampersand are disallowed as mnemonics.
Mappings from arbitrary characters to mnemonic keys may be defined
by providing a property
MNEMONIC_{unicode char}={KeyEvent.VK_ constant name} within a bundle
accessible by abbot.i18n.Strings
. If no such
mapping is defined, a VK_ code is guessed by checking if there can be
found a keystroke mapping for the original character.
KeyStrokeMap
,
Strings
public static boolean useMnemonics()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |