KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > awt > Checkbox


1 /*
2  * @(#)Checkbox.java 1.84 04/05/05
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package java.awt;
8
9 import java.awt.peer.CheckboxPeer;
10 import java.awt.event.*;
11 import java.util.EventListener JavaDoc;
12 import java.io.ObjectOutputStream JavaDoc;
13 import java.io.ObjectInputStream JavaDoc;
14 import java.io.IOException JavaDoc;
15 import javax.accessibility.*;
16
17
18 /**
19  * A check box is a graphical component that can be in either an
20  * "on" (<code>true</code>) or "off" (<code>false</code>) state.
21  * Clicking on a check box changes its state from
22  * "on" to "off," or from "off" to "on."
23  * <p>
24  * The following code example creates a set of check boxes in
25  * a grid layout:
26  * <p>
27  * <hr><blockquote><pre>
28  * setLayout(new GridLayout(3, 1));
29  * add(new Checkbox("one", null, true));
30  * add(new Checkbox("two"));
31  * add(new Checkbox("three"));
32  * </pre></blockquote><hr>
33  * <p>
34  * This image depicts the check boxes and grid layout
35  * created by this code example:
36  * <p>
37  * <img SRC="doc-files/Checkbox-1.gif" alt="The following context describes the graphic."
38  * ALIGN=center HSPACE=10 VSPACE=7>
39  * <p>
40  * The button labeled <code>one</code> is in the "on" state, and the
41  * other two are in the "off" state. In this example, which uses the
42  * <code>GridLayout</code> class, the states of the three check
43  * boxes are set independently.
44  * <p>
45  * Alternatively, several check boxes can be grouped together under
46  * the control of a single object, using the
47  * <code>CheckboxGroup</code> class.
48  * In a check box group, at most one button can be in the "on"
49  * state at any given time. Clicking on a check box to turn it on
50  * forces any other check box in the same group that is on
51  * into the "off" state.
52  *
53  * @version 1.84 05/05/04
54  * @author Sami Shaio
55  * @see java.awt.GridLayout
56  * @see java.awt.CheckboxGroup
57  * @since JDK1.0
58  */

59 public class Checkbox extends Component JavaDoc implements ItemSelectable JavaDoc, Accessible {
60
61     static {
62         /* ensure that the necessary native libraries are loaded */
63     Toolkit.loadLibraries();
64         if (!GraphicsEnvironment.isHeadless()) {
65             initIDs();
66         }
67     }
68
69     /**
70      * The label of the Checkbox.
71      * This field can be null.
72      * @serial
73      * @see #getLabel()
74      * @see #setLabel(label)
75      */

76     String JavaDoc label;
77
78     /**
79      * The state of the <code>Checkbox</code>.
80      * @serial
81      * @see #getState()
82      * @see #setState(state)
83      */

84     boolean state;
85
86     /**
87      * The check box group.
88      * This field can be null indicating that the checkbox
89      * is not a group checkbox.
90      * @serial
91      * @see #getCheckBoxGroup()
92      * @see #setCheckBoxGroup(CheckBoxGroup)
93      */

94     CheckboxGroup JavaDoc group;
95
96     transient ItemListener itemListener;
97
98     private static final String JavaDoc base = "checkbox";
99     private static int nameCounter = 0;
100
101     /*
102      * JDK 1.1 serialVersionUID
103      */

104     private static final long serialVersionUID = 7270714317450821763L;
105
106     /**
107      * Helper function for setState and CheckboxGroup.setSelectedCheckbox
108      * Should remain package-private.
109      */

110     void setStateInternal(boolean state) {
111     this.state = state;
112     CheckboxPeer peer = (CheckboxPeer)this.peer;
113     if (peer != null) {
114         peer.setState(state);
115     }
116     }
117
118     /**
119      * Creates a check box with an empty string for its label.
120      * The state of this check box is set to "off," and it is not
121      * part of any check box group.
122      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
123      * returns true
124      * @see java.awt.GraphicsEnvironment#isHeadless
125      */

126     public Checkbox() throws HeadlessException JavaDoc {
127         this("", false, null);
128     }
129
130     /**
131      * Creates a check box with the specified label. The state
132      * of this check box is set to "off," and it is not part of
133      * any check box group.
134      *
135      * @param label a string label for this check box,
136      * or <code>null</code> for no label.
137      * @exception HeadlessException if
138      * <code>GraphicsEnvironment.isHeadless</code>
139      * returns <code>true</code>
140      * @see java.awt.GraphicsEnvironment#isHeadless
141      */

142     public Checkbox(String JavaDoc label) throws HeadlessException JavaDoc {
143     this(label, false, null);
144     }
145
146     /**
147      * Creates a check box with the specified label
148      * and sets the specified state.
149      * This check box is not part of any check box group.
150      *
151      * @param label a string label for this check box,
152      * or <code>null</code> for no label
153      * @param state the initial state of this check box
154      * @exception HeadlessException if
155      * <code>GraphicsEnvironment.isHeadless</code>
156      * returns <code>true</code>
157      * @see java.awt.GraphicsEnvironment#isHeadless
158      */

159     public Checkbox(String JavaDoc label, boolean state) throws HeadlessException JavaDoc {
160         this(label, state, null);
161     }
162
163     /**
164      * Constructs a Checkbox with the specified label, set to the
165      * specified state, and in the specified check box group.
166      *
167      * @param label a string label for this check box,
168      * or <code>null</code> for no label.
169      * @param state the initial state of this check box.
170      * @param group a check box group for this check box,
171      * or <code>null</code> for no group.
172      * @exception HeadlessException if
173      * <code>GraphicsEnvironment.isHeadless</code>
174      * returns <code>true</code>
175      * @see java.awt.GraphicsEnvironment#isHeadless
176      * @since JDK1.1
177      */

178     public Checkbox(String JavaDoc label, boolean state, CheckboxGroup JavaDoc group)
179         throws HeadlessException JavaDoc {
180         GraphicsEnvironment.checkHeadless();
181     this.label = label;
182     this.state = state;
183     this.group = group;
184     if (state && (group != null)) {
185         group.setSelectedCheckbox(this);
186     }
187     }
188
189     /**
190      * Creates a check box with the specified label, in the specified
191      * check box group, and set to the specified state.
192      *
193      * @param label a string label for this check box,
194      * or <code>null</code> for no label.
195      * @param group a check box group for this check box,
196      * or <code>null</code> for no group.
197      * @param state the initial state of this check box.
198      * @exception HeadlessException if
199      * <code>GraphicsEnvironment.isHeadless</code>
200      * returns <code>true</code>
201      * @see java.awt.GraphicsEnvironment#isHeadless
202      * @since JDK1.1
203      */

204     public Checkbox(String JavaDoc label, CheckboxGroup JavaDoc group, boolean state)
205         throws HeadlessException JavaDoc {
206         this(label, state, group);
207     }
208
209     /**
210      * Constructs a name for this component. Called by
211      * <code>getName</code> when the name is <code>null</code>.
212      *
213      * @return a name for this component
214      */

215     String JavaDoc constructComponentName() {
216         synchronized (getClass()) {
217         return base + nameCounter++;
218     }
219     }
220
221     /**
222      * Creates the peer of the Checkbox. The peer allows you to change the
223      * look of the Checkbox without changing its functionality.
224      *
225      * @see java.awt.Toolkit#createCheckbox(java.awt.Checkbox)
226      * @see java.awt.Component#getToolkit()
227      */

228     public void addNotify() {
229         synchronized (getTreeLock()) {
230         if (peer == null)
231             peer = getToolkit().createCheckbox(this);
232         super.addNotify();
233     }
234     }
235
236     /**
237      * Gets the label of this check box.
238      *
239      * @return the label of this check box, or <code>null</code>
240      * if this check box has no label.
241      * @see #setLabel(String)
242      */

243     public String JavaDoc getLabel() {
244     return label;
245     }
246
247     /**
248      * Sets this check box's label to be the string argument.
249      *
250      * @param label a string to set as the new label, or
251      * <code>null</code> for no label.
252      * @see #getLabel
253      */

254     public void setLabel(String JavaDoc label) {
255         boolean testvalid = false;
256
257     synchronized (this) {
258         if (label != this.label && (this.label == null ||
259                     !this.label.equals(label))) {
260             this.label = label;
261         CheckboxPeer peer = (CheckboxPeer)this.peer;
262         if (peer != null) {
263             peer.setLabel(label);
264         }
265         testvalid = true;
266         }
267     }
268         
269     // This could change the preferred size of the Component.
270
if (testvalid && valid) {
271         invalidate();
272     }
273     }
274
275     /**
276      * Determines whether this check box is in the "on" or "off" state.
277      * The boolean value <code>true</code> indicates the "on" state,
278      * and <code>false</code> indicates the "off" state.
279      *
280      * @return the state of this check box, as a boolean value
281      * @see #setState
282      */

283     public boolean getState() {
284     return state;
285     }
286
287     /**
288      * Sets the state of this check box to the specified state.
289      * The boolean value <code>true</code> indicates the "on" state,
290      * and <code>false</code> indicates the "off" state.
291      *
292      * <p>Note that this method should be primarily used to
293      * initialize the state of the checkbox. Programmatically
294      * setting the state of the checkbox will <i>not</i> trigger
295      * an <code>ItemEvent</code>. The only way to trigger an
296      * <code>ItemEvent</code> is by user interaction.
297      *
298      * @param state the boolean state of the check box
299      * @see #getState
300      */

301     public void setState(boolean state) {
302     /* Cannot hold check box lock when calling group.setSelectedCheckbox. */
303         CheckboxGroup JavaDoc group = this.group;
304     if (group != null) {
305         if (state) {
306         group.setSelectedCheckbox(this);
307         } else if (group.getSelectedCheckbox() == this) {
308         state = true;
309         }
310     }
311     setStateInternal(state);
312     }
313
314     /**
315      * Returns an array (length 1) containing the checkbox
316      * label or null if the checkbox is not selected.
317      * @see ItemSelectable
318      */

319     public Object JavaDoc[] getSelectedObjects() {
320         if (state) {
321             Object JavaDoc[] items = new Object JavaDoc[1];
322             items[0] = label;
323             return items;
324         }
325         return null;
326     }
327
328     /**
329      * Determines this check box's group.
330      * @return this check box's group, or <code>null</code>
331      * if the check box is not part of a check box group.
332      * @see #setCheckboxGroup(CheckboxGroup)
333      */

334     public CheckboxGroup JavaDoc getCheckboxGroup() {
335     return group;
336     }
337
338     /**
339      * Sets this check box's group to the specified check box group.
340      * If this check box is already in a different check box group,
341      * it is first taken out of that group.
342      * <p>
343      * If the state of this check box is <code>true</code> and the new
344      * group already has a check box selected, this check box's state
345      * is changed to <code>false</code>. If the state of this check
346      * box is <code>true</code> and the new group has no check box
347      * selected, this check box becomes the selected checkbox for
348      * the new group and its state is <code>true</code>.
349      *
350      * @param g the new check box group, or <code>null</code>
351      * to remove this check box from any check box group
352      * @see #getCheckboxGroup
353      */

354     public void setCheckboxGroup(CheckboxGroup JavaDoc g) {
355         CheckboxGroup JavaDoc oldGroup;
356         boolean oldState;
357
358         /* Do nothing if this check box has already belonged
359          * to the check box group g.
360          */

361         if (this.group == g) {
362             return;
363         }
364
365     synchronized (this) {
366             oldGroup = this.group;
367             oldState = getState();
368
369         this.group = g;
370         CheckboxPeer peer = (CheckboxPeer)this.peer;
371         if (peer != null) {
372         peer.setCheckboxGroup(g);
373         }
374         if (this.group != null && getState()) {
375             if (this.group.getSelectedCheckbox() != null) {
376                 setState(false);
377             } else {
378                 this.group.setSelectedCheckbox(this);
379             }
380         }
381     }
382
383         /* Locking check box below could cause deadlock with
384          * CheckboxGroup's setSelectedCheckbox method.
385          *
386          * Fix for 4726853 by kdm@sparc.spb.su
387          * Here we should check if this check box was selected
388          * in the previous group and set selected check box to
389          * null for that group if so.
390          */

391         if (oldGroup != null && oldState) {
392             oldGroup.setSelectedCheckbox(null);
393         }
394     }
395
396     /**
397      * Adds the specified item listener to receive item events from
398      * this check box. Item events are sent to listeners in response
399      * to user input, but not in response to calls to setState().
400      * If l is null, no exception is thrown and no action is performed.
401      *
402      * @param l the item listener
403      * @see #removeItemListener
404      * @see #getItemListeners
405      * @see #setState
406      * @see java.awt.event.ItemEvent
407      * @see java.awt.event.ItemListener
408      * @since JDK1.1
409      */

410     public synchronized void addItemListener(ItemListener l) {
411     if (l == null) {
412         return;
413     }
414         itemListener = AWTEventMulticaster.add(itemListener, l);
415         newEventsOnly = true;
416     }
417
418     /**
419      * Removes the specified item listener so that the item listener
420      * no longer receives item events from this check box.
421      * If l is null, no exception is thrown and no action is performed.
422      *
423      * @param l the item listener
424      * @see #addItemListener
425      * @see #getItemListeners
426      * @see java.awt.event.ItemEvent
427      * @see java.awt.event.ItemListener
428      * @since JDK1.1
429      */

430     public synchronized void removeItemListener(ItemListener l) {
431     if (l == null) {
432         return;
433     }
434         itemListener = AWTEventMulticaster.remove(itemListener, l);
435     }
436
437     /**
438      * Returns an array of all the item listeners
439      * registered on this checkbox.
440      *
441      * @return all of this checkbox's <code>ItemListener</code>s
442      * or an empty array if no item
443      * listeners are currently registered
444      *
445      * @see #addItemListener
446      * @see #removeItemListener
447      * @see java.awt.event.ItemEvent
448      * @see java.awt.event.ItemListener
449      * @since 1.4
450      */

451     public synchronized ItemListener[] getItemListeners() {
452         return (ItemListener[]) (getListeners(ItemListener.class));
453     }
454
455     /**
456      * Returns an array of all the objects currently registered
457      * as <code><em>Foo</em>Listener</code>s
458      * upon this <code>Checkbox</code>.
459      * <code><em>Foo</em>Listener</code>s are registered using the
460      * <code>add<em>Foo</em>Listener</code> method.
461      *
462      * <p>
463      * You can specify the <code>listenerType</code> argument
464      * with a class literal, such as
465      * <code><em>Foo</em>Listener.class</code>.
466      * For example, you can query a
467      * <code>Checkbox</code> <code>c</code>
468      * for its item listeners with the following code:
469      *
470      * <pre>ItemListener[] ils = (ItemListener[])(c.getListeners(ItemListener.class));</pre>
471      *
472      * If no such listeners exist, this method returns an empty array.
473      *
474      * @param listenerType the type of listeners requested; this parameter
475      * should specify an interface that descends from
476      * <code>java.util.EventListener</code>
477      * @return an array of all objects registered as
478      * <code><em>Foo</em>Listener</code>s on this checkbox,
479      * or an empty array if no such
480      * listeners have been added
481      * @exception ClassCastException if <code>listenerType</code>
482      * doesn't specify a class or interface that implements
483      * <code>java.util.EventListener</code>
484      *
485      * @see #getItemListeners
486      * @since 1.3
487      */

488     public <T extends EventListener JavaDoc> T[] getListeners(Class JavaDoc<T> listenerType) {
489     EventListener JavaDoc l = null;
490     if (listenerType == ItemListener.class) {
491         l = itemListener;
492     } else {
493         return super.getListeners(listenerType);
494     }
495     return AWTEventMulticaster.getListeners(l, listenerType);
496     }
497
498     // REMIND: remove when filtering is done at lower level
499
boolean eventEnabled(AWTEvent JavaDoc e) {
500         if (e.id == ItemEvent.ITEM_STATE_CHANGED) {
501             if ((eventMask & AWTEvent.ITEM_EVENT_MASK) != 0 ||
502                 itemListener != null) {
503                 return true;
504             }
505             return false;
506         }
507         return super.eventEnabled(e);
508     }
509
510     /**
511      * Processes events on this check box.
512      * If the event is an instance of <code>ItemEvent</code>,
513      * this method invokes the <code>processItemEvent</code> method.
514      * Otherwise, it calls its superclass's <code>processEvent</code> method.
515      * <p>Note that if the event parameter is <code>null</code>
516      * the behavior is unspecified and may result in an
517      * exception.
518      *
519      * @param e the event
520      * @see java.awt.event.ItemEvent
521      * @see #processItemEvent
522      * @since JDK1.1
523      */

524     protected void processEvent(AWTEvent JavaDoc e) {
525         if (e instanceof ItemEvent) {
526             processItemEvent((ItemEvent)e);
527             return;
528         }
529     super.processEvent(e);
530     }
531
532     /**
533      * Processes item events occurring on this check box by
534      * dispatching them to any registered
535      * <code>ItemListener</code> objects.
536      * <p>
537      * This method is not called unless item events are
538      * enabled for this component. Item events are enabled
539      * when one of the following occurs:
540      * <p><ul>
541      * <li>An <code>ItemListener</code> object is registered
542      * via <code>addItemListener</code>.
543      * <li>Item events are enabled via <code>enableEvents</code>.
544      * </ul>
545      * <p>Note that if the event parameter is <code>null</code>
546      * the behavior is unspecified and may result in an
547      * exception.
548      *
549      * @param e the item event
550      * @see java.awt.event.ItemEvent
551      * @see java.awt.event.ItemListener
552      * @see #addItemListener
553      * @see java.awt.Component#enableEvents
554      * @since JDK1.1
555      */

556     protected void processItemEvent(ItemEvent e) {
557         ItemListener listener = itemListener;
558         if (listener != null) {
559             listener.itemStateChanged(e);
560         }
561     }
562
563     /**
564      * Returns a string representing the state of this <code>Checkbox</code>.
565      * This method is intended to be used only for debugging purposes, and the
566      * content and format of the returned string may vary between
567      * implementations. The returned string may be empty but may not be
568      * <code>null</code>.
569      *
570      * @return the parameter string of this check box
571      */

572     protected String JavaDoc paramString() {
573     String JavaDoc str = super.paramString();
574     String JavaDoc label = this.label;
575     if (label != null) {
576         str += ",label=" + label;
577     }
578     return str + ",state=" + state;
579     }
580
581
582     /* Serialization support.
583      */

584     
585     /*
586      * Serialized data version
587      * @serial
588      */

589     private int checkboxSerializedDataVersion = 1;
590
591     /**
592      * Writes default serializable fields to stream. Writes
593      * a list of serializable <code>ItemListeners</code>
594      * as optional data. The non-serializable
595      * <code>ItemListeners</code> are detected and
596      * no attempt is made to serialize them.
597      *
598      * @param s the <code>ObjectOutputStream</code> to write
599      * @serialData <code>null</code> terminated sequence of 0
600      * or more pairs; the pair consists of a <code>String</code>
601      * and an <code>Object</code>; the <code>String</code> indicates
602      * the type of object and is one of the following:
603      * <code>itemListenerK</code> indicating an
604      * <code>ItemListener</code> object
605      *
606      * @see AWTEventMulticaster#save(ObjectOutputStream, String, EventListener)
607      * @see java.awt.Component#itemListenerK
608      * @see #readObject(ObjectInputStream)
609      */

610     private void writeObject(ObjectOutputStream JavaDoc s)
611       throws java.io.IOException JavaDoc
612     {
613       s.defaultWriteObject();
614
615       AWTEventMulticaster.save(s, itemListenerK, itemListener);
616       s.writeObject(null);
617     }
618
619     /**
620      * Reads the <code>ObjectInputStream</code> and if it
621      * isn't <code>null</code> adds a listener to receive
622      * item events fired by the <code>Checkbox</code>.
623      * Unrecognized keys or values will be ignored.
624      *
625      * @param s the <code>ObjectInputStream</code> to read
626      * @exception HeadlessException if
627      * <code>GraphicsEnvironment.isHeadless</code> returns
628      * <code>true</code>
629      * @serial
630      * @see #removeItemListener(ItemListener)
631      * @see #addItemListener(ItemListener)
632      * @see java.awt.GraphicsEnvironment#isHeadless
633      * @see #writeObject(ObjectOutputStream)
634      */

635     private void readObject(ObjectInputStream JavaDoc s)
636       throws ClassNotFoundException JavaDoc, IOException JavaDoc, HeadlessException JavaDoc
637     {
638       GraphicsEnvironment.checkHeadless();
639       s.defaultReadObject();
640
641       Object JavaDoc keyOrNull;
642       while(null != (keyOrNull = s.readObject())) {
643     String JavaDoc key = ((String JavaDoc)keyOrNull).intern();
644
645     if (itemListenerK == key)
646       addItemListener((ItemListener)(s.readObject()));
647
648     else // skip value for unrecognized key
649
s.readObject();
650       }
651     }
652
653     /**
654      * Initialize JNI field and method ids
655      */

656     private static native void initIDs();
657
658
659 /////////////////
660
// Accessibility support
661
////////////////
662

663
664     /**
665      * Gets the AccessibleContext associated with this Checkbox.
666      * For checkboxes, the AccessibleContext takes the form of an
667      * AccessibleAWTCheckbox.
668      * A new AccessibleAWTCheckbox is created if necessary.
669      *
670      * @return an AccessibleAWTCheckbox that serves as the
671      * AccessibleContext of this Checkbox
672      */

673     public AccessibleContext getAccessibleContext() {
674         if (accessibleContext == null) {
675             accessibleContext = new AccessibleAWTCheckbox();
676         }
677         return accessibleContext;
678     }
679
680     /**
681      * This class implements accessibility support for the
682      * <code>Checkbox</code> class. It provides an implementation of the
683      * Java Accessibility API appropriate to checkbox user-interface elements.
684      */

685     protected class AccessibleAWTCheckbox extends AccessibleAWTComponent
686         implements ItemListener, AccessibleAction, AccessibleValue
687     {
688         /*
689          * JDK 1.3 serialVersionUID
690          */

691         private static final long serialVersionUID = 7881579233144754107L;
692
693     public AccessibleAWTCheckbox() {
694         super();
695         Checkbox.this.addItemListener(this);
696     }
697
698     /**
699      * Fire accessible property change events when the state of the
700      * toggle button changes.
701      */

702         public void itemStateChanged(ItemEvent e) {
703             Checkbox JavaDoc cb = (Checkbox JavaDoc) e.getSource();
704             if (Checkbox.this.accessibleContext != null) {
705                 if (cb.getState()) {
706                     Checkbox.this.accessibleContext.firePropertyChange(
707                             AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
708                             null, AccessibleState.CHECKED);
709                 } else {
710                     Checkbox.this.accessibleContext.firePropertyChange(
711                             AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
712                             AccessibleState.CHECKED, null);
713                 }
714             }
715         }
716
717         /**
718          * Get the AccessibleAction associated with this object. In the
719          * implementation of the Java Accessibility API for this class,
720      * return this object, which is responsible for implementing the
721          * AccessibleAction interface on behalf of itself.
722      *
723      * @return this object
724          */

725         public AccessibleAction getAccessibleAction() {
726             return this;
727         }
728
729         /**
730          * Get the AccessibleValue associated with this object. In the
731          * implementation of the Java Accessibility API for this class,
732      * return this object, which is responsible for implementing the
733          * AccessibleValue interface on behalf of itself.
734      *
735      * @return this object
736          */

737         public AccessibleValue getAccessibleValue() {
738             return this;
739         }
740
741         /**
742          * Returns the number of Actions available in this object.
743          * If there is more than one, the first one is the "default"
744          * action.
745          *
746          * @return the number of Actions in this object
747          */

748         public int getAccessibleActionCount() {
749             return 0; // To be fully implemented in a future release
750
}
751
752         /**
753          * Return a description of the specified action of the object.
754          *
755          * @param i zero-based index of the actions
756          */

757         public String JavaDoc getAccessibleActionDescription(int i) {
758             return null; // To be fully implemented in a future release
759
}
760
761         /**
762          * Perform the specified Action on the object
763          *
764          * @param i zero-based index of actions
765          * @return true if the the action was performed; else false.
766          */

767         public boolean doAccessibleAction(int i) {
768             return false; // To be fully implemented in a future release
769
}
770
771     /**
772      * Get the value of this object as a Number. If the value has not been
773      * set, the return value will be null.
774      *
775      * @return value of the object
776      * @see #setCurrentAccessibleValue
777      */

778     public Number JavaDoc getCurrentAccessibleValue() {
779         return null; // To be fully implemented in a future release
780
}
781
782     /**
783      * Set the value of this object as a Number.
784      *
785      * @return True if the value was set; else False
786      * @see #getCurrentAccessibleValue
787      */

788     public boolean setCurrentAccessibleValue(Number JavaDoc n) {
789         return false; // To be fully implemented in a future release
790
}
791
792     /**
793      * Get the minimum value of this object as a Number.
794      *
795      * @return Minimum value of the object; null if this object does not
796      * have a minimum value
797      * @see #getMaximumAccessibleValue
798      */

799     public Number JavaDoc getMinimumAccessibleValue() {
800         return null; // To be fully implemented in a future release
801
}
802
803     /**
804      * Get the maximum value of this object as a Number.
805      *
806      * @return Maximum value of the object; null if this object does not
807      * have a maximum value
808      * @see #getMinimumAccessibleValue
809      */

810     public Number JavaDoc getMaximumAccessibleValue() {
811         return null; // To be fully implemented in a future release
812
}
813
814         /**
815          * Get the role of this object.
816          *
817          * @return an instance of AccessibleRole describing the role of
818      * the object
819          * @see AccessibleRole
820          */

821         public AccessibleRole getAccessibleRole() {
822             return AccessibleRole.CHECK_BOX;
823         }
824
825         /**
826          * Get the state set of this object.
827          *
828          * @return an instance of AccessibleState containing the current state
829          * of the object
830          * @see AccessibleState
831          */

832         public AccessibleStateSet getAccessibleStateSet() {
833             AccessibleStateSet states = super.getAccessibleStateSet();
834             if (getState()) {
835                 states.add(AccessibleState.CHECKED);
836             }
837             return states;
838         }
839
840
841     } // inner class AccessibleAWTCheckbox
842

843 }
844
Popular Tags