public static class Options.LabelOption extends Options.Option<String,JLabel>
XMLSerializable.OldVersionCompatible, XMLSerializable.VersionSupportTypeROOT_ELEMENT_NAME| Modifier | Constructor and Description |
|---|---|
protected |
Options.LabelOption(org.jdom.Element element) |
|
Options.LabelOption(String name,
String label)
Constructs a LabelOption.
|
| Modifier and Type | Method and Description |
|---|---|
protected JLabel |
createComponent()
Create a graphical component representing this option.
|
Icon |
getIcon()
Returns the currently set icon, or null if none is set.
|
String |
getValueFromString(String value)
Convert a String into an instance of the object type used by this option.
|
protected void |
handleSetEnabled(JLabel component,
boolean enabled)
Set the enabled state of a component.
|
boolean |
isCenterText()
Returns true if the label text will be drawn centered
|
boolean |
isRestorePreferenceApplies()
Returns true if calling
Options.restorePreferences() should restore this setting to its value saved in preferences, and
Options.Option.shouldSaveValue() returns true |
boolean |
isSelectable() |
boolean |
isVisibleOnlyWhenEnabled()
Returns true if the component for this option will only be visible if the option is enabled.
|
void |
setCenterText(boolean centerText)
Whether to draw the label text centered
|
void |
setIcon(Icon icon)
Sets an icon that will be displayed to the left of the label.
|
void |
setSelectable(boolean selectable)
Sets whether or not the text in this label is selectable by the user.
|
protected void |
setValueOnComponent(JLabel component,
String value)
Set the value on this component.
|
void |
setVisible(boolean visible)
Sets the visibility of the graphical component that displays this option together with its label and
makes appropriate changes to the size of the window (if any) that contains the graphical component.
|
void |
setVisibleOnlyWhenEnabled(boolean visibleOnlyWhenEnabled)
If true, then calling
Options.Option.setEnabled(boolean) will additionally have the effect of calling setVisible(boolean) |
boolean |
shouldSaveValue()
If this method returns false, then the option will not save its value to preferences, nor will it save its value when you call
Options.valuesToXML(String) on its parent options. |
org.jdom.Element |
toXML()
Convert object to a JDOM element.
|
addChangeListener, addChildOptionsDependent, addDependent, fromXML, generateValidValue, getComponent, getDefaultValue, getDescription, getDescriptionAndState, getDisplayedLabel, getExtraPersistentInformation, getLabel, getName, getParentOptions, getPossibleValues, getValue, getValueAsString, getValueAsString, getVerticalWeight, hideWarningMessage, isAdvanced, isEnabled, isFillHorizontalSpace, isProOnly, isRestoreDefaultApplies, isSpanningComponent, isVisible, moveToOptions, removeChangeListener, restoreDefault, setAdvanced, setAlwaysUsesDefaultPreferenceLocation, setDefaultValue, setDescription, setDisabledValue, setEnabled, setExtraPersistentInformation, setFillHorizontalSpace, setHidden, setLabelComponent, setPreferredHeight, setPreferredWidth, setProOnly, setRestoreDefaultApplies, setRestorePreferenceApplies, setShouldSaveValue, setSpanningComponent, setValue, setValue, setValueFromString, setVerticalWeight, setWarningMessage, toStringprotected Options.LabelOption(org.jdom.Element element)
throws XMLSerializationException
XMLSerializationExceptionpublic Options.LabelOption(String name, String label)
Options.addLabel(String)name - the name to be used for referencing this option. For example from scripts or source code which wish to programmatically get or set the value of this option.label - The label that this option will takepublic boolean isRestorePreferenceApplies()
Options.OptionOptions.restorePreferences() should restore this setting to its value saved in preferences, and
Options.Option.shouldSaveValue() returns trueisRestorePreferenceApplies in class Options.Option<String,JLabel>Options.restorePreferences() should restore this setting to its value saved in preferences, and
() returns truepublic boolean shouldSaveValue()
Options.OptionOptions.valuesToXML(String) on its parent options.shouldSaveValue in class Options.Option<String,JLabel>Options.valuesToXML(String)Options.Option.isRestorePreferenceApplies()public org.jdom.Element toXML()
XMLSerializableXMLSerializable.fromXML(org.jdom.Element) can completely
restore the objects representation.
It is recommended that the returned element use XMLSerializable.ROOT_ELEMENT_NAME as its name,
in which case it must not define an attribute called "type". In this case,
fromXML, will be called with an element whose name may differ from the element
return from this function. This recommendation allows a more compact representation
of the XML can be stored.
This method generally should not be called directly. Instead, you should usually call
XMLSerializer.classToXML(String, XMLSerializable)
which calls this method internally.
PluginDocument implementations of this method may choose to throw an XMLSerializationException,
enclosed in a RuntimeException.toXML in interface XMLSerializabletoXML in class Options.Option<String,JLabel>public String getValueFromString(String value)
Options.OptionOptions.Option.getValueAsString(Object) .getValueFromString in class Options.Option<String,JLabel>value - the string representation of the object valueprotected void setValueOnComponent(JLabel component, String value)
Options.OptionsetValueOnComponent in class Options.Option<String,JLabel>component - a component return from Options.Option.createComponent()value - the value to set.protected JLabel createComponent()
Options.OptionOptions.Option.getValue().
The implementation is also responsible for making sure that the returned component
listens to any changes made to itself and
reflects those changes in the value of this option
using the Options.Option.setValue(Object) method.
This method will only be called once for each instance of an Option.
After it has been called, getComponent() will return a cached copy of it.createComponent in class Options.Option<String,JLabel>public boolean isSelectable()
public void setSelectable(boolean selectable)
selectable - true for this label to be selectable by the userIllegalStateException - if this label has had its component instantiated already.UnsupportedOperationException - if setCenterText(boolean) or setIcon(javax.swing.Icon) have been called on this labelpublic void setCenterText(boolean centerText)
centerText - true if you want the label text to be drawn centeredUnsupportedOperationException - if setSelectable(boolean) has been called on this labelpublic boolean isCenterText()
public void setIcon(Icon icon)
icon - the icon to setUnsupportedOperationException - if setSelectable(boolean) has been called on this labelpublic Icon getIcon()
public void setVisible(boolean visible)
Options.OptionsetVisible in class Options.Option<String,JLabel>visible - whether or not the graphical component that displays this option should be visible.public void setVisibleOnlyWhenEnabled(boolean visibleOnlyWhenEnabled)
Options.Option.setEnabled(boolean) will additionally have the effect of calling setVisible(boolean)visibleOnlyWhenEnabled - public boolean isVisibleOnlyWhenEnabled()
protected void handleSetEnabled(JLabel component, boolean enabled)
Options.OptionhandleSetEnabled in class Options.Option<String,JLabel>component - the component to set the enabled state ofenabled - true if it should be enabled