public class TextBinding
extends java.lang.Object
The syntax of the string content is as follows:
Simple mnemonic: the first character preceded by the first _
character will be treated as the mnemonic. For example, "E_xit" will cause
the text to become "Exit" and the mnemonic will be "x". This is the most
common designation of a mnemonic, and the skin for a control will present the
mnemonic in the string with an underline. To prevent _
from being
treated as the mnemonic prefix character, repeat it twice in a row. A
mnemonic is not required.
Extended mnemonic: an optional representation of a mnemonic is
_(c)
, where c
is the mnemonic character. For example,
"Exit_(q)" will cause the text to become "Exit" and the
extendedMnemonicText
to become "(q)". This is typically provided in
translated strings to support mnemonics where the main text does not have any
characters that map to keyboard keys. In these cases, the skin for the
control will typically present the mnemonic surrounded by parentheses. The
skin will also honor the hiding and presentation of the extended mnemonic
string on platforms where the mnemonic is only displayed when the mnemonic
modifier key is pressed.
Modifier and Type | Class and Description |
---|---|
static class |
TextBinding.MnemonicKeyCombination
A modified version of KeyCharacterCombination, which matches
on the text property of a KeyEvent instead of on the KeyCode.
|
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
extendedMnemonicText
The extended mnemonic text (if it exists).
|
private java.lang.String |
mnemonic
The mnemonic or
null if there is no mnemonic. |
private java.lang.String |
MNEMONIC_SYMBOL
the marker symbol used when parsing for mnemonics
|
private int |
mnemonicIndex
The index of the mnemonic character in the text property or -1 if there
is no mnemonic character in the text.
|
private KeyCombination |
mnemonicKeyCombination |
private java.lang.String |
text
The text with any markup for the mnemonic and accelerator removed.
|
Constructor and Description |
---|
TextBinding(java.lang.String s)
Creates a new TextBinding instance from the given string.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getExtendedMnemonicText()
Returns the extended mnemonic text (if it exists).
|
java.lang.String |
getMnemonic()
Returns the mnemonic or
null if there is no
mnemonic. |
int |
getMnemonicIndex()
Returns the index of the mnemonic character in the text property or -1 if
there is no mnemonic character in the text.
|
KeyCombination |
getMnemonicKeyCombination()
Returns the mnemonic KeyCombination or
null if there is no
mnemonic. |
java.lang.String |
getText()
Returns the text with any markup for the mnemonic and accelerator removed
|
private void |
parseAndSplit(java.lang.String s)
Parse and split the given string into the appropriate segments.
|
private java.lang.String MNEMONIC_SYMBOL
private java.lang.String text
private java.lang.String mnemonic
null
if there is no mnemonic.private KeyCombination mnemonicKeyCombination
private int mnemonicIndex
_c
syntax was used to specify the mnemonic.private java.lang.String extendedMnemonicText
public TextBinding(java.lang.String s)
s
- the action text stringpublic java.lang.String getText()
public java.lang.String getMnemonic()
null
if there is no
mnemonic.null
if there is no
mnemonicpublic KeyCombination getMnemonicKeyCombination()
null
if there is no
mnemonic.null
if there is no
mnemonicpublic int getMnemonicIndex()
_c
syntax was used to specify the mnemonic.public java.lang.String getExtendedMnemonicText()
private void parseAndSplit(java.lang.String s)