public class TextBinding extends 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.
|
Constructor and Description |
---|
TextBinding(String s)
Creates a new TextBinding instance from the given string.
|
Modifier and Type | Method and Description |
---|---|
String |
getExtendedMnemonicText()
Returns the extended mnemonic text (if it exists).
|
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. |
String |
getText()
Returns the text with any markup for the mnemonic and accelerator removed
|
public TextBinding(String s)
s
- the action text stringpublic String getText()
public 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 String getExtendedMnemonicText()
Copyright © 2020. All rights reserved.