public class SelectOption extends HTMLTagAttributes implements java.io.Serializable
This example creates a SelectOption object named item1 that is initially selected.
SelectOption item1 = new SelectOption("Item1", "item1", true);
System.out.println(item1.getTag());
Here is the output of the SelectOption tag:
<option value="item1" selected="selected">Item1</option>
SelectOption objects generate the following events:
SelectFormElement,
Serialized Form| Constructor and Description |
|---|
SelectOption()
Constructs a default SelectOption object.
|
SelectOption(java.lang.String text,
java.lang.String value)
Constructs a SelectOption object with the specified viewable text and initial
input value.
|
SelectOption(java.lang.String text,
java.lang.String value,
boolean selected)
Constructs a SelectOption object with the specified viewable text,
initial input value, and initial selected value.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Adds the VetoableChangeListener.
|
java.lang.String |
getDirection()
Returns the direction of the text interpretation.
|
java.lang.String |
getFOTag()
Returns a comment tag.
|
java.lang.String |
getLanguage()
Returns the language of the input element.
|
java.lang.String |
getTag()
Returns the select option tag.
|
java.lang.String |
getTag(java.lang.String text)
Returns the select option tag with the new viewable option text.
|
java.lang.String |
getText()
Returns the viewable option text.
|
java.lang.String |
getValue()
Returns the input value used when the field is submitted.
|
boolean |
isSelected()
Indicates if the option defaults to being selected.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes the PropertyChangeListener from the internal list.
|
void |
removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Removes the VetoableChangeListener from the internal list.
|
void |
setDirection(java.lang.String dir)
Sets the direction of the text interpretation.
|
void |
setLanguage(java.lang.String lang)
Sets the language of the input tag.
|
void |
setSelected(boolean selected)
Sets whether the option defaults as being selected.
|
void |
setText(java.lang.String text)
Sets the option text with the specified viewable text.
|
void |
setValue(java.lang.String value)
Sets the input value used when the field is submitted.
|
java.lang.String |
toString()
Returns the String representation of the select option tag.
|
addPropertyChangeListener, getAttributes, getAttributeString, setAttributespublic SelectOption()
public SelectOption(java.lang.String text,
java.lang.String value)
text - The veiwable option text.value - The input value used when the field is submitted.public SelectOption(java.lang.String text,
java.lang.String value,
boolean selected)
text - The viewable option text.value - The input value used when the field is submitted.selected - Whether the option defaults as being selected.public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener - The VetoableChangeListener.removeVetoableChangeListener(java.beans.VetoableChangeListener)public java.lang.String getDirection()
public java.lang.String getLanguage()
public java.lang.String getFOTag()
getFOTag in interface HTMLTagElementpublic java.lang.String getTag()
getTag in interface HTMLTagElementpublic java.lang.String getTag(java.lang.String text)
text - The new option text.public java.lang.String getText()
public java.lang.String getValue()
public boolean isSelected()
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener in class HTMLTagAttributeslistener - The PropertyChangeListener.HTMLTagAttributes.addPropertyChangeListener(java.beans.PropertyChangeListener)public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener - The VetoableChangeListener.addVetoableChangeListener(java.beans.VetoableChangeListener)public void setDirection(java.lang.String dir)
throws java.beans.PropertyVetoException
dir - The direction. One of the following constants
defined in HTMLConstants: LTR or RTL.java.beans.PropertyVetoException - If a change is vetoed.HTMLConstantspublic void setLanguage(java.lang.String lang)
throws java.beans.PropertyVetoException
lang - The language. Example language tags include:
en and en-US.java.beans.PropertyVetoException - If a change is vetoed.public void setSelected(boolean selected)
throws java.beans.PropertyVetoException
selected - Whether the option defaults as selected.java.beans.PropertyVetoException - If a change is vetoed.public void setText(java.lang.String text)
throws java.beans.PropertyVetoException
text - The option text.java.beans.PropertyVetoException - If a change is vetoed.public void setValue(java.lang.String value)
throws java.beans.PropertyVetoException
value - The input value.java.beans.PropertyVetoException - If a change is vetoed.public java.lang.String toString()
toString in class java.lang.Object