|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.richclient.core.LabelInfo
public final class LabelInfo
An immutable parameter object consisting of the text, mnemonic character and mnemonic character
index that may be associated with a labeled component. This class also acts as a factory for
creating instances of itself based on a string descriptor that adheres to some simple syntax
rules as described in the javadoc for the valueOf(String)
method.
The syntax used for the label info descriptor is just the text to be displayed by the label with an ampersand (&) optionally inserted before the character that is to be used as a mnemonic for the label.
Example: To create a label with the text My Label
and the capital L as a mnemonic,
use the following descriptor:
My &Label
A backslash character (\) can be used to escape ampersand characters that are to be displayed as part of the label's text. For example:
Save \& Run
Only one non-escaped backslash can appear in the label descriptor. Attempting to specify more than one mnemonic character will result in an exception being thrown. TODO finish comment regarding backslash chars in props file Note that for label descriptors provided in properties files, an extra backslash will be required to avoid the single backslash being interpreted as a special character.
Constructor Summary | |
---|---|
LabelInfo(String text)
Creates a new LabelInfo with the given text and no specified mnemonic. |
|
LabelInfo(String text,
int mnemonic)
Creates a new LabelInfo with the given text and mnemonic character. |
|
LabelInfo(String text,
int mnemonic,
int mnemonicIndex)
Creates a new LabelInfo with the given text, mnemonic character and mnemonic index. |
Method Summary | |
---|---|
void |
configureButton(AbstractButton button)
Configures the given button with the properties held in this instance. |
void |
configureLabel(JLabel label)
Configures the given label with the parameters from this instance. |
void |
configureLabelFor(JLabel label,
JComponent component)
Configures the given label with the property values described by this instance and then sets it as the label for the given component. |
boolean |
equals(Object obj)
|
int |
getMnemonic()
Returns the character that is to be treated as the mnemonic character for the label. |
int |
getMnemonicIndex()
Returns the index within the label text of the mnemonic character. |
String |
getText()
Returns the text to be displayed by the label. |
int |
hashCode()
|
String |
toString()
|
static LabelInfo |
valueOf(String labelDescriptor)
Creates a new LabelInfo instance by parsing the given label descriptor to determine
the label's text and mnemonic character. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public LabelInfo(String text)
LabelInfo
with the given text and no specified mnemonic.
text
- The text to be displayed by the label. This may be an empty string but
cannot be null.
IllegalArgumentException
- if text
is null.public LabelInfo(String text, int mnemonic)
LabelInfo
with the given text and mnemonic character.
text
- The text to be displayed by the label. This may be an empty string but cannot
be null.mnemonic
- The character from the label text that acts as a mnemonic.
IllegalArgumentException
- if text
is null or if mnemonic
is a
negative value.public LabelInfo(String text, int mnemonic, int mnemonicIndex)
LabelInfo
with the given text, mnemonic character and mnemonic index.
text
- The text to be displayed by the label. This may be an empty string but cannot
be null.mnemonic
- The character from the label text that acts as a mnemonic.mnemonicIndex
- The zero-based index of the mnemonic character within the label text.
If the specified label text is an empty string, this property will be ignored and set to -1.
IllegalArgumentException
- if text
is null, if mnemonic
is a negative
value, if mnemonicIndex
is less than -1 or if mnemonicIndex
is outside the
length of text
.Method Detail |
---|
public static LabelInfo valueOf(String labelDescriptor)
LabelInfo
instance by parsing the given label descriptor to determine
the label's text and mnemonic character. The syntax rules for the descriptor are as follows:
labelDescriptor
- The label descriptor. The text may be null or empty, in which case a
blank LabelInfo
instance will be returned.
LabelInfo
instance that is described by the given descriptor.
Never returns null.
IllegalArgumentException
- if labelDescriptor
violates any of the syntax rules
described above.public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
public void configureLabel(JLabel label)
label
- The label that is to be configured.
IllegalArgumentException
- if label
is null.public void configureLabelFor(JLabel label, JComponent component)
label
- The label to be configured.component
- The component that the label is 'for'.
IllegalArgumentException
- if either argument is null.JLabel.setLabelFor(java.awt.Component)
public void configureButton(AbstractButton button)
button
- The button to be configured.
IllegalArgumentException
- if button
is null.public String getText()
public int getMnemonic()
public int getMnemonicIndex()
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |