42 |
import javax.accessibility.Accessible; |
import javax.accessibility.Accessible; |
43 |
import javax.accessibility.AccessibleContext; |
import javax.accessibility.AccessibleContext; |
44 |
import javax.accessibility.AccessibleRole; |
import javax.accessibility.AccessibleRole; |
45 |
|
import javax.swing.event.ChangeEvent; |
46 |
|
import javax.swing.event.ChangeListener; |
47 |
|
|
48 |
|
|
49 |
/** |
/** |
50 |
* DOCUMENT ME! |
* This class represents JRadioButtonMenuItem. Its behaviour is very similar |
51 |
|
* to JRadioButton. Just like JRadioButton, user can check and uncheck this |
52 |
|
* menu item by clicking on it. JRadioButtonMenuItem uses ToggleButtonModel |
53 |
|
* to keep track of its selection. If the JRadioButtonMenuItem is included in |
54 |
|
* the button group, then only one JRadioButtonMenuItem can be selected at |
55 |
|
* one time. |
56 |
*/ |
*/ |
57 |
public class JRadioButtonMenuItem extends JMenuItem implements Accessible |
public class JRadioButtonMenuItem extends JMenuItem implements Accessible |
58 |
{ |
{ |
59 |
private static final long serialVersionUID = 8482658191548521743L; |
private static final long serialVersionUID = 8482658191548521743L; |
60 |
|
|
61 |
|
/** name for the UI delegate for this radio button menu item. */ |
62 |
private static final String uiClassID = "RadioButtonMenuItemUI"; |
private static final String uiClassID = "RadioButtonMenuItemUI"; |
63 |
|
|
64 |
/** |
/** |
70 |
} |
} |
71 |
|
|
72 |
/** |
/** |
73 |
* Creates a new JRadioButtonMenuItem object. |
* Creates a new JRadioButtonMenuItem with specified icon |
74 |
* |
* |
75 |
* @param icon DOCUMENT ME! |
* @param icon Icon to be used for this menu item |
76 |
*/ |
*/ |
77 |
public JRadioButtonMenuItem(Icon icon) |
public JRadioButtonMenuItem(Icon icon) |
78 |
{ |
{ |
80 |
} |
} |
81 |
|
|
82 |
/** |
/** |
83 |
* Creates a new JRadioButtonMenuItem object. |
* Creates a new JRadioButtonMenuItem with specified label |
84 |
* |
* |
85 |
* @param text DOCUMENT ME! |
* @param text Label for this menu item |
86 |
*/ |
*/ |
87 |
public JRadioButtonMenuItem(String text) |
public JRadioButtonMenuItem(String text) |
88 |
{ |
{ |
90 |
} |
} |
91 |
|
|
92 |
/** |
/** |
93 |
* Creates a new JRadioButtonMenuItem object. |
* Creates a new JRadioButtonMenuItem using specified action |
94 |
* |
* |
95 |
* @param action DOCUMENT ME! |
* @param action Action for this menu item |
96 |
*/ |
*/ |
97 |
public JRadioButtonMenuItem(Action action) |
public JRadioButtonMenuItem(Action action) |
98 |
{ |
{ |
101 |
} |
} |
102 |
|
|
103 |
/** |
/** |
104 |
* Creates a new JRadioButtonMenuItem object. |
* Creates a new JRadioButtonMenuItem with specified label and icon |
105 |
* |
* |
106 |
* @param text DOCUMENT ME! |
* @param text Label for this menu item |
107 |
* @param icon DOCUMENT ME! |
* @param icon Icon for this menu item |
108 |
*/ |
*/ |
109 |
public JRadioButtonMenuItem(String text, Icon icon) |
public JRadioButtonMenuItem(String text, Icon icon) |
110 |
{ |
{ |
112 |
} |
} |
113 |
|
|
114 |
/** |
/** |
115 |
* Creates a new JRadioButtonMenuItem object. |
* Creates a new JRadioButtonMenuItem with specified label |
116 |
|
* and marked selected if 'selected' is true. |
117 |
* |
* |
118 |
* @param text DOCUMENT ME! |
* @param text Text for this menu item |
119 |
* @param selected DOCUMENT ME! |
* @param selected Selected state of this menu item |
120 |
*/ |
*/ |
121 |
public JRadioButtonMenuItem(String text, boolean selected) |
public JRadioButtonMenuItem(String text, boolean selected) |
122 |
{ |
{ |
124 |
} |
} |
125 |
|
|
126 |
/** |
/** |
127 |
* Creates a new JRadioButtonMenuItem object. |
* Creates a new JRadioButtonMenuItem with specified icon |
128 |
|
* and given selected state |
129 |
* |
* |
130 |
* @param icon DOCUMENT ME! |
* @param icon Icon for this menu item |
131 |
* @param selected DOCUMENT ME! |
* @param selected Selected state for this menu item |
132 |
*/ |
*/ |
133 |
public JRadioButtonMenuItem(Icon icon, boolean selected) |
public JRadioButtonMenuItem(Icon icon, boolean selected) |
134 |
{ |
{ |
136 |
} |
} |
137 |
|
|
138 |
/** |
/** |
139 |
* Creates a new JRadioButtonMenuItem object. |
* Creates a new JRadioButtonMenuItem with specified label, |
140 |
|
* icon and selected state. |
141 |
* |
* |
142 |
* @param text DOCUMENT ME! |
* @param text Label for this menu item |
143 |
* @param icon DOCUMENT ME! |
* @param icon Icon to be use for this menu item |
144 |
* @param selected DOCUMENT ME! |
* @param selected selected state of this menu item |
145 |
*/ |
*/ |
146 |
public JRadioButtonMenuItem(String text, Icon icon, boolean selected) |
public JRadioButtonMenuItem(String text, Icon icon, boolean selected) |
147 |
{ |
{ |
150 |
model.setSelected(selected); |
model.setSelected(selected); |
151 |
} |
} |
152 |
|
|
|
/** |
|
|
* DOCUMENT ME! |
|
|
* |
|
|
* @param stream DOCUMENT ME! |
|
|
* |
|
|
* @throws IOException DOCUMENT ME! |
|
|
*/ |
|
153 |
private void writeObject(ObjectOutputStream stream) throws IOException |
private void writeObject(ObjectOutputStream stream) throws IOException |
154 |
{ |
{ |
|
// TODO |
|
155 |
} |
} |
156 |
|
|
157 |
/** |
/** |
158 |
* DOCUMENT ME! |
* This method returns a name to identify which look and feel class will be |
159 |
|
* the UI delegate for the menuItem. |
160 |
* |
* |
161 |
* @return $returnType$ DOCUMENT ME! |
* @return The Look and Feel classID. "JRadioButtonMenuItemUI" |
162 |
*/ |
*/ |
163 |
public String getUIClassID() |
public String getUIClassID() |
164 |
{ |
{ |
166 |
} |
} |
167 |
|
|
168 |
/** |
/** |
169 |
* DOCUMENT ME! |
* This method overrides JComponent.requestFocus with an empty |
170 |
|
* implementation, since JRadioButtonMenuItems should not |
171 |
|
* receve focus in general. |
172 |
*/ |
*/ |
173 |
public void requestFocus() |
public void requestFocus() |
174 |
{ |
{ |
175 |
// TODO |
// Should do nothing here |
176 |
} |
} |
177 |
|
|
178 |
/** |
/** |
179 |
* DOCUMENT ME! |
* A string that describes this JRadioButtonMenuItem. Normally only used |
180 |
|
* for debugging. |
181 |
* |
* |
182 |
* @return $returnType$ DOCUMENT ME! |
* @return A string describing this JRadioButtonMenuItem |
183 |
*/ |
*/ |
184 |
protected String paramString() |
protected String paramString() |
185 |
{ |
{ |
186 |
return "JRadioButtonMenuItem"; |
return "JRadioButtonMenuItem"; |
187 |
} |
} |
188 |
|
|
|
/** |
|
|
* DOCUMENT ME! |
|
|
* |
|
|
* @return $returnType$ DOCUMENT ME! |
|
|
*/ |
|
189 |
public AccessibleContext getAccessibleContext() |
public AccessibleContext getAccessibleContext() |
190 |
{ |
{ |
191 |
if (accessibleContext == null) |
if (accessibleContext == null) |
194 |
return accessibleContext; |
return accessibleContext; |
195 |
} |
} |
196 |
|
|
|
/** |
|
|
* DOCUMENT ME! |
|
|
*/ |
|
197 |
protected class AccessibleJRadioButtonMenuItem extends AccessibleJMenuItem |
protected class AccessibleJRadioButtonMenuItem extends AccessibleJMenuItem |
198 |
{ |
{ |
199 |
private static final long serialVersionUID = 4381471510145292179L; |
private static final long serialVersionUID = 4381471510145292179L; |
205 |
{ |
{ |
206 |
} |
} |
207 |
|
|
|
/** |
|
|
* DOCUMENT ME! |
|
|
* |
|
|
* @return $returnType$ DOCUMENT ME! |
|
|
*/ |
|
208 |
public AccessibleRole getAccessibleRole() |
public AccessibleRole getAccessibleRole() |
209 |
{ |
{ |
210 |
return AccessibleRole.RADIO_BUTTON; |
return AccessibleRole.RADIO_BUTTON; |