Interface Mnemonicable
- All Known Implementing Classes:
BasicHeaderUI.DescriptionPane
,JXLabel
,JXTaskPane
- Author:
- Karl George Schaefer
-
Method Summary
Modifier and TypeMethodDescriptionint
Returns the character, as an index, that the look and feel should provide decoration for as representing the mnemonic character.int
Returns the keyboard mnemonic for this component.void
setDisplayedMnemonicIndex
(int index) Provides a hint to the look and feel as to which character in the text should be decorated to represent the mnemonic.void
setMnemonic
(int mnemonic) Sets the keyboard mnemonic on this component.
-
Method Details
-
getMnemonic
int getMnemonic()Returns the keyboard mnemonic for this component.- Returns:
- the keyboard mnemonic
-
setMnemonic
void setMnemonic(int mnemonic) Sets the keyboard mnemonic on this component. The mnemonic is the key which when combined with the look and feel's mouseless modifier (usually Alt) will activate this component.A mnemonic must correspond to a single key on the keyboard and should be specified using one of the
VK_XXX
keycodes defined injava.awt.event.KeyEvent
. Mnemonics are case-insensitive, therefore a key event with the corresponding keycode would cause the button to be activated whether or not the Shift modifier was pressed.- Parameters:
mnemonic
- the key code which represents the mnemonic- See Also:
-
getDisplayedMnemonicIndex
int getDisplayedMnemonicIndex()Returns the character, as an index, that the look and feel should provide decoration for as representing the mnemonic character.- Returns:
- index representing mnemonic character
- Since:
- 1.4
- See Also:
-
setDisplayedMnemonicIndex
Provides a hint to the look and feel as to which character in the text should be decorated to represent the mnemonic. Not all look and feels may support this. A value of -1 indicates either there is no mnemonic, the mnemonic character is not contained in the string, or the developer does not wish the mnemonic to be displayed.The value of this is updated as the properties relating to the mnemonic change (such as the mnemonic itself, the text...). You should only ever have to call this if you do not wish the default character to be underlined. For example, if the text was 'Save As', with a mnemonic of 'a', and you wanted the 'A' to be decorated, as 'Save As', you would have to invoke
setDisplayedMnemonicIndex(5)
after invokingsetMnemonic(KeyEvent.VK_A)
.- Parameters:
index
- Index into the String to underline- Throws:
IllegalArgumentException
- will be thrown ifindex
is >= length of the text, or < -1- Since:
- 1.4
- See Also:
-