javax.swing.text.html
public class: Option [javadoc |
source]
java.lang.Object
javax.swing.text.html.Option
All Implemented Interfaces:
java$io$Serializable
Value for the ListModel used to represent
<option> elements. This is the object
installed as items of the DefaultComboBoxModel
used to represent the <select> element.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeansTM
has been added to the java.beans
package.
Please see java.beans.XMLEncoder .
- author:
Timothy
- Prinzing
Constructor: |
public Option(AttributeSet attr) {
this.attr = attr.copyAttributes();
selected = (attr.getAttribute(HTML.Attribute.SELECTED) != null);
}
Creates a new Option object. Parameters:
attr - the attributes associated with the
option element. The attributes are copied to
ensure they won't change.
|
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from javax.swing.text.html.Option Detail: |
public AttributeSet getAttributes() {
return attr;
}
Fetch the attributes associated with this option. |
public String getLabel() {
return label;
}
Fetch the label associated with the option. |
public String getValue() {
String value = (String) attr.getAttribute(HTML.Attribute.VALUE);
if (value == null) {
value = label;
}
return value;
}
Convenience method to return the string associated
with the value attribute. If the
value has not been specified, the label will be
returned. |
public boolean isSelected() {
return selected;
}
Fetches the selection state associated with this option. |
public void setLabel(String label) {
this.label = label;
}
Sets the label to be used for the option. |
protected void setSelection(boolean state) {
selected = state;
}
|
public String toString() {
return label;
}
String representation is the label. |