FileDocCategorySizeDatePackage
Option.javaAPI DocJava SE 6 API2604Tue Jun 10 00:27:00 BST 2008javax.swing.text.html

Option

public class Option extends Object implements 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 {@link java.beans.XMLEncoder}.

author
Timothy Prinzing
version
1.12 03/28/06

Fields Summary
private boolean
selected
private String
label
private AttributeSet
attr
Constructors Summary
public Option(AttributeSet attr)
Creates a new Option object.

param
attr the attributes associated with the option element. The attributes are copied to ensure they won't change.

	this.attr = attr.copyAttributes();
	selected = (attr.getAttribute(HTML.Attribute.SELECTED) != null);
    
Methods Summary
public javax.swing.text.AttributeSetgetAttributes()
Fetch the attributes associated with this option.

	return attr;
    
public java.lang.StringgetLabel()
Fetch the label associated with the option.

	return label;
    
public java.lang.StringgetValue()
Convenience method to return the string associated with the value attribute. If the value has not been specified, the label will be returned.

	String value = (String) attr.getAttribute(HTML.Attribute.VALUE);
	if (value == null) {
	    value = label;
	}
	return value;
    
public booleanisSelected()
Fetches the selection state associated with this option.

	return selected;
    
public voidsetLabel(java.lang.String label)
Sets the label to be used for the option.

	this.label = label;
    
protected voidsetSelection(boolean state)
Sets the selected state.

	selected = state;
    
public java.lang.StringtoString()
String representation is the label.

	return label;