1 7 package javax.swing.text.html; 8 9 import java.awt.*; 10 import javax.swing.*; 11 import javax.swing.text.*; 12 13 22 public class Option { 23 24 31 public Option(AttributeSet attr) { 32 this.attr = attr.copyAttributes(); 33 selected = (attr.getAttribute(HTML.Attribute.SELECTED) != null); 34 } 35 36 39 public void setLabel(String label) { 40 this.label = label; 41 } 42 43 46 public String getLabel() { 47 return label; 48 } 49 50 53 public AttributeSet getAttributes() { 54 return attr; 55 } 56 57 60 public String toString() { 61 return label; 62 } 63 64 67 protected void setSelection(boolean state) { 68 selected = state; 69 } 70 71 74 public boolean isSelected() { 75 return selected; 76 } 77 78 84 public String getValue() { 85 String value = (String ) attr.getAttribute(HTML.Attribute.VALUE); 86 if (value == null) { 87 value = label; 88 } 89 return value; 90 } 91 92 private boolean selected; 93 private String label; 94 private AttributeSet attr; 95 } 96 97 | Popular Tags |