1 7 package javax.swing; 8 9 import java.util.EventListener ; 10 11 import java.awt.*; 12 import java.awt.event.*; 13 import java.awt.image.*; 14 15 import java.io.ObjectOutputStream ; 16 import java.io.ObjectInputStream ; 17 import java.io.IOException ; 18 19 import javax.swing.plaf.*; 20 import javax.accessibility.*; 21 22 55 public class JRadioButtonMenuItem extends JMenuItem implements Accessible { 56 60 private static final String uiClassID = "RadioButtonMenuItemUI"; 61 62 65 public JRadioButtonMenuItem() { 66 this(null, null, false); 67 } 68 69 75 public JRadioButtonMenuItem(Icon icon) { 76 this(null, icon, false); 77 } 78 79 84 public JRadioButtonMenuItem(String text) { 85 this(text, null, false); 86 } 87 88 97 public JRadioButtonMenuItem(Action a) { 98 this(); 99 setAction(a); 100 } 101 102 109 public JRadioButtonMenuItem(String text, Icon icon) { 110 this(text, icon, false); 111 } 112 113 120 public JRadioButtonMenuItem(String text, boolean selected) { 121 this(text); 122 setSelected(selected); 123 } 124 125 133 public JRadioButtonMenuItem(Icon icon, boolean selected) { 134 this(null, icon, selected); 135 } 136 137 145 public JRadioButtonMenuItem(String text, Icon icon, boolean selected) { 146 super(text, icon); 147 setModel(new JToggleButton.ToggleButtonModel ()); 148 setSelected(selected); 149 setFocusable(false); 150 } 151 152 159 public String getUIClassID() { 160 return uiClassID; 161 } 162 163 168 private void writeObject(ObjectOutputStream s) throws IOException { 169 s.defaultWriteObject(); 170 if (getUIClassID().equals(uiClassID)) { 171 byte count = JComponent.getWriteObjCounter(this); 172 JComponent.setWriteObjCounter(this, --count); 173 if (count == 0 && ui != null) { 174 ui.installUI(this); 175 } 176 } 177 } 178 179 180 191 protected String paramString() { 192 return super.paramString(); 193 } 194 195 199 208 public AccessibleContext getAccessibleContext() { 209 if (accessibleContext == null) { 210 accessibleContext = new AccessibleJRadioButtonMenuItem(); 211 } 212 return accessibleContext; 213 } 214 215 230 protected class AccessibleJRadioButtonMenuItem extends AccessibleJMenuItem { 231 237 public AccessibleRole getAccessibleRole() { 238 return AccessibleRole.RADIO_BUTTON; 239 } 240 } } 242 243 | Popular Tags |