be.ugent.caagt.swirl.actions
Class Description
java.lang.Object
be.ugent.caagt.swirl.actions.Description
public class Description
extends java.lang.Object
An object of this class describes caption, mnemonic and accelerator key of a
GUI component. It is initialized by a single description string (either at
construction time or by calling
setDescription(String)
) which is then
internally split into different parts. For example, the description string
"Javadoc inde&x search [shift F1]" will be split into the caption
'Javadoc index search', mnemonic 'X' and accelerator key shift-F1.
Accelerator keys, if present, are written between square brackets as the
last part of the description string and use the conventions of method
javax.swing.KeyStroke.getKeyStroke(String)
. Mnemonics are indicated
by placing an ampersand in front of the first occurrence of that letter in
the string. The name of the action is obtained by removing from the
description string the bracketed accelerator
key, any surrounding white space and all ampersands.
Two consecutive ampersands are
not interpreted as a mnemonic, but result in a single ampersand in the
name.
In most cases this class should not be used directly, for buttons and menu
items can most easily be internationalized using actions that extend
SimpleAction
.
Description(String description) - Create a new object based on the given description string.
|
KeyStroke | getAcceleratorKey() - Return the accelerator key for this description, or 0 when no key was
given.
|
static Description | getCancelButtonDescription() - Return a default description for a Cancel-button.
|
String | getCaption() - Return the caption for this description.
|
int | getMnemonic() - Return the mnemonic for this description
|
int | getMnemonicIndex() - Return the index of the mnemonic for this description, or -1 when no
mnemonic was given.
|
static Description | getNoButtonDescription() - Return a default description for a No-button.
|
static Description | getOkButtonDescription() - Return a default description for an OK-button.
|
static Description | getYesButtonDescription() - Return a default description for a Yes-button.
|
void | init(AbstractButton button) - Initialize caption and mnemonic for the given button, according to this
description.
|
void | init(Action action) - Initialize caption, mnemonic and accelerator key for the given action,
according to this description.
|
void | initApproveButton(JFileChooser chooser) - Initialize the approve button and title of the given file chooser, according to this
description.
|
void | setDescription(String newDescription) - (Re)initialize this object based on the given description string.
|
Description
public Description(String description)
Create a new object based on the given description string.
getAcceleratorKey
public KeyStroke getAcceleratorKey()
Return the accelerator key for this description, or 0 when no key was
given.
getCancelButtonDescription
public static Description getCancelButtonDescription()
Return a default description for a Cancel-button. The caption and
mnemonics are the same as those used for an option pane in the
look-and-feel of the application, and are therefore internationalized.
getCaption
public String getCaption()
Return the caption for this description.
getMnemonic
public int getMnemonic()
Return the mnemonic for this description
getMnemonicIndex
public int getMnemonicIndex()
Return the index of the mnemonic for this description, or -1 when no
mnemonic was given.
getNoButtonDescription
public static Description getNoButtonDescription()
Return a default description for a No-button. The caption and mnemonics
are the same as those used for an option pane in the look-and-feel of
the application, and therefore internationalized.
getOkButtonDescription
public static Description getOkButtonDescription()
Return a default description for an OK-button. The caption and mnemonics
are the same as those used for an option pane in the look-and-feel of
the application, and are therefore internationalized.
getYesButtonDescription
public static Description getYesButtonDescription()
Return a default description for a Yes-button. The caption and mnemonics
are the same as those used for an option pane in the look-and-feel of
the application, and therefore internationalized.
init
public void init(AbstractButton button)
Initialize caption and mnemonic for the given button, according to this
description. If the button is a menu item, also set the accelerator
key.
init
public void init(Action action)
Initialize caption, mnemonic and accelerator key for the given action,
according to this description.
initApproveButton
public void initApproveButton(JFileChooser chooser)
Initialize the approve button and title of the given file chooser, according to this
description.
setDescription
public final void setDescription(String newDescription)
(Re)initialize this object based on the given description string.