/[classpath]/classpath/javax/swing/JCheckBoxMenuItem.java
ViewVC logotype

Diff of /classpath/javax/swing/JCheckBoxMenuItem.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by mark, Sat Jun 26 16:06:48 2004 UTC revision 1.8 by mark, Thu Jul 22 19:45:39 2004 UTC
# Line 45  import javax.accessibility.AccessibleRol Line 45  import javax.accessibility.AccessibleRol
45    
46    
47  /**  /**
48   * DOCUMENT ME!   * This class represents JCheckBoxMenuItem. Its behaviour is very similar
49     * to JCheckBoxButton. Just like the JCheckBoxButton, user can check and
50     * uncheck this menu item by clicking on it. Also setSelected()/setState()
51     * can be use used for the same purpose. JCheckBoxMenuItem uses
52     * ToggleButtonModel to keep track of its selection.
53   */   */
54  public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,  public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
55                                                              Accessible                                                              Accessible
56  {  {
57    private static final long serialVersionUID = -6676402307973384715L;    private static final long serialVersionUID = -6676402307973384715L;
58    
59      /** name for the UI delegate for this menuItem. */
60    private static final String uiClassID = "CheckBoxMenuItemUI";    private static final String uiClassID = "CheckBoxMenuItemUI";
61    
62      /** Indicates whether this menu item is checked. */
63    private boolean state;    private boolean state;
64    private Object[] selectedObjects;  
65      /**
66       * This array contains text of this menu item if this menu item is in
67       * checked state and null it is not.
68       */
69      private Object[] selectedObjects = new Object[1];
70    
71    /**    /**
72     * Creates a new JCheckBoxMenuItem object.     * Creates a new JCheckBoxMenuItem object.
# Line 65  public class JCheckBoxMenuItem extends J Line 77  public class JCheckBoxMenuItem extends J
77    }    }
78    
79    /**    /**
80     * Creates a new JCheckBoxMenuItem object.     * Creates a new JCheckBoxMenuItem with given icon
81     *     *
82     * @param icon DOCUMENT ME!     * @param icon Icon for this menu item
83     */     */
84    public JCheckBoxMenuItem(Icon icon)    public JCheckBoxMenuItem(Icon icon)
85    {    {
# Line 75  public class JCheckBoxMenuItem extends J Line 87  public class JCheckBoxMenuItem extends J
87    }    }
88    
89    /**    /**
90     * Creates a new JCheckBoxMenuItem object.     * Creates a new JCheckBoxMenuItem with given label
91     *     *
92     * @param text DOCUMENT ME!     * @param text Label for this menu item
93     */     */
94    public JCheckBoxMenuItem(String text)    public JCheckBoxMenuItem(String text)
95    {    {
# Line 85  public class JCheckBoxMenuItem extends J Line 97  public class JCheckBoxMenuItem extends J
97    }    }
98    
99    /**    /**
100     * Creates a new JCheckBoxMenuItem object.     * Creates a new JCheckBoxMenuItem using given action
101     *     *
102     * @param action DOCUMENT ME!     * @param action Action for this menu item.
103     */     */
104    public JCheckBoxMenuItem(Action action)    public JCheckBoxMenuItem(Action action)
105    {    {
# Line 96  public class JCheckBoxMenuItem extends J Line 108  public class JCheckBoxMenuItem extends J
108    }    }
109    
110    /**    /**
111     * Creates a new JCheckBoxMenuItem object.     * Creates a new JCheckBoxMenuItem object with given label and icon
112     *     *
113     * @param text DOCUMENT ME!     * @param text Label for this menu item
114     * @param icon DOCUMENT ME!     * @param icon Icon for this menu item
115     */     */
116    public JCheckBoxMenuItem(String text, Icon icon)    public JCheckBoxMenuItem(String text, Icon icon)
117    {    {
# Line 107  public class JCheckBoxMenuItem extends J Line 119  public class JCheckBoxMenuItem extends J
119    }    }
120    
121    /**    /**
122     * Creates a new JCheckBoxMenuItem object.     * Creates a new JCheckBoxMenuItem object using specified label and
123       * marked as checked if given 'state' is true
124     *     *
125     * @param text DOCUMENT ME!     * @param text Label for this menu item
126     * @param state DOCUMENT ME!     * @param state True if this item should be in checked state and false otherwise
127     */     */
128    public JCheckBoxMenuItem(String text, boolean state)    public JCheckBoxMenuItem(String text, boolean state)
129    {    {
# Line 118  public class JCheckBoxMenuItem extends J Line 131  public class JCheckBoxMenuItem extends J
131    }    }
132    
133    /**    /**
134     * Creates a new JCheckBoxMenuItem object.     * Creates a new JCheckBoxMenuItem object with given label, icon,
135       * and marked as checked if given 'state' is true
136     *     *
137     * @param text DOCUMENT ME!     * @param text Label for this menu item
138     * @param icon DOCUMENT ME!     * @param icon icon for this menu item
139     * @param state DOCUMENT ME!     * @param state  True if this item should be in checked state and false otherwise
140     */     */
141    public JCheckBoxMenuItem(String text, Icon icon, boolean state)    public JCheckBoxMenuItem(String text, Icon icon, boolean state)
142    {    {
# Line 131  public class JCheckBoxMenuItem extends J Line 145  public class JCheckBoxMenuItem extends J
145      this.state = state;      this.state = state;
146    }    }
147    
   /**  
    * DOCUMENT ME!  
    *  
    * @param stream DOCUMENT ME!  
    *  
    * @throws IOException DOCUMENT ME!  
    */  
148    private void writeObject(ObjectOutputStream stream) throws IOException    private void writeObject(ObjectOutputStream stream) throws IOException
149    {    {
     // TODO  
150    }    }
151    
152    /**    /**
153     * DOCUMENT ME!     * This method returns a name to identify which look and feel class will be
154       * the UI delegate for the menuItem.
155     *     *
156     * @return $returnType$ DOCUMENT ME!     * @return The Look and Feel classID. "JCheckBoxMenuItemUI"
157     */     */
158    public String getUIClassID()    public String getUIClassID()
159    {    {
# Line 154  public class JCheckBoxMenuItem extends J Line 161  public class JCheckBoxMenuItem extends J
161    }    }
162    
163    /**    /**
164     * DOCUMENT ME!     * Returns checked state for this check box menu item.
165     *     *
166     * @return $returnType$ DOCUMENT ME!     * @return Returns true if this menu item is in checked state
167       * and false otherwise.
168     */     */
169    public boolean getState()    public boolean getState()
170    {    {
# Line 164  public class JCheckBoxMenuItem extends J Line 172  public class JCheckBoxMenuItem extends J
172    }    }
173    
174    /**    /**
175     * DOCUMENT ME!     * Sets state for this check box menu item. If
176       * given 'state' is true, then mark menu item as checked,
177       * and uncheck this menu item otherwise.
178       *
179       * @param state new state for this menu item
180     *     *
    * @param state DOCUMENT ME!  
181     */     */
182    public synchronized void setState(boolean state)    public synchronized void setState(boolean state)
183    {    {
# Line 174  public class JCheckBoxMenuItem extends J Line 185  public class JCheckBoxMenuItem extends J
185    }    }
186    
187    /**    /**
188     * DOCUMENT ME!     * This method returns array containing label of this
189       * menu item if it is selected and null otherwise.
190     *     *
191     * @return $returnType$ DOCUMENT ME!     * @return Array containing label of this
192       * menu item if this menu item is selected or null otherwise.
193     */     */
194    public Object[] getSelectedObjects()    public Object[] getSelectedObjects()
195    {    {
196        if (state == true)
197          selectedObjects[0] = this.getText();
198        else
199          selectedObjects[0] = null;
200    
201      return selectedObjects;      return selectedObjects;
202    }    }
203    
204    /**    /**
205     * DOCUMENT ME!      * This method overrides JComponent.requestFocus with an empty
206        * implementation, since JCheckBoxMenuItems should not
207        * receve focus in general.
208     */     */
209    public void requestFocus()    public void requestFocus()
210    {    {
211      // TODO      //  Should do nothing here
212    }    }
213    
214    /**    /**
215     * DOCUMENT ME!     * A string that describes this JCheckBoxMenuItem. Normally only used
216       * for debugging.
217     *     *
218     * @return $returnType$ DOCUMENT ME!     * @return A string describing this JCheckBoxMenuItem
219     */     */
220    protected String paramString()    protected String paramString()
221    {    {
222      return "JCheckBoxMenuItem";      return "JCheckBoxMenuItem";
223    }    }
224    
   /**  
    * DOCUMENT ME!  
    *  
    * @return $returnType$ DOCUMENT ME!  
    */  
225    public AccessibleContext getAccessibleContext()    public AccessibleContext getAccessibleContext()
226    {    {
227      if (accessibleContext == null)      if (accessibleContext == null)
# Line 214  public class JCheckBoxMenuItem extends J Line 230  public class JCheckBoxMenuItem extends J
230      return accessibleContext;      return accessibleContext;
231    }    }
232    
   /**  
    * DOCUMENT ME!  
    */  
233    protected class AccessibleJCheckBoxMenuItem extends AccessibleJMenuItem    protected class AccessibleJCheckBoxMenuItem extends AccessibleJMenuItem
234    {    {
235      private static final long serialVersionUID = 1079958073579370777L;      private static final long serialVersionUID = 1079958073579370777L;
# Line 228  public class JCheckBoxMenuItem extends J Line 241  public class JCheckBoxMenuItem extends J
241      {      {
242      }      }
243    
     /**  
      * DOCUMENT ME!  
      *  
      * @return $returnType$ DOCUMENT ME!  
      */  
244      public AccessibleRole getAccessibleRole()      public AccessibleRole getAccessibleRole()
245      {      {
246        return AccessibleRole.CHECK_BOX;        return AccessibleRole.CHECK_BOX;

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26