Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.desktop/share/classes/java/awt/Checkbox.java
41152 views
1
/*
2
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package java.awt;
27
28
import java.awt.event.ItemEvent;
29
import java.awt.event.ItemListener;
30
import java.awt.peer.CheckboxPeer;
31
import java.io.IOException;
32
import java.io.ObjectInputStream;
33
import java.io.ObjectOutputStream;
34
import java.io.Serial;
35
import java.util.EventListener;
36
37
import javax.accessibility.Accessible;
38
import javax.accessibility.AccessibleAction;
39
import javax.accessibility.AccessibleContext;
40
import javax.accessibility.AccessibleRole;
41
import javax.accessibility.AccessibleState;
42
import javax.accessibility.AccessibleStateSet;
43
import javax.accessibility.AccessibleValue;
44
45
/**
46
* A check box is a graphical component that can be in either an
47
* "on" ({@code true}) or "off" ({@code false}) state.
48
* Clicking on a check box changes its state from
49
* "on" to "off," or from "off" to "on."
50
* <p>
51
* The following code example creates a set of check boxes in
52
* a grid layout:
53
*
54
* <hr><blockquote><pre>
55
* setLayout(new GridLayout(3, 1));
56
* add(new Checkbox("one", null, true));
57
* add(new Checkbox("two"));
58
* add(new Checkbox("three"));
59
* </pre></blockquote><hr>
60
* <p>
61
* This image depicts the check boxes and grid layout
62
* created by this code example:
63
* <p>
64
* <img src="doc-files/Checkbox-1.gif" alt="The following context describes the
65
* graphic." style="margin: 7px 10px;">
66
* <p>
67
* The button labeled {@code one} is in the "on" state, and the
68
* other two are in the "off" state. In this example, which uses the
69
* {@code GridLayout} class, the states of the three check
70
* boxes are set independently.
71
* <p>
72
* Alternatively, several check boxes can be grouped together under
73
* the control of a single object, using the
74
* {@code CheckboxGroup} class.
75
* In a check box group, at most one button can be in the "on"
76
* state at any given time. Clicking on a check box to turn it on
77
* forces any other check box in the same group that is on
78
* into the "off" state.
79
*
80
* @author Sami Shaio
81
* @see java.awt.GridLayout
82
* @see java.awt.CheckboxGroup
83
* @since 1.0
84
*/
85
public class Checkbox extends Component implements ItemSelectable, Accessible {
86
87
static {
88
/* ensure that the necessary native libraries are loaded */
89
Toolkit.loadLibraries();
90
if (!GraphicsEnvironment.isHeadless()) {
91
initIDs();
92
}
93
}
94
95
/**
96
* The label of the Checkbox.
97
* This field can be null.
98
* @serial
99
* @see #getLabel()
100
* @see #setLabel(String)
101
*/
102
String label;
103
104
/**
105
* The state of the {@code Checkbox}.
106
* @serial
107
* @see #getState()
108
* @see #setState(boolean)
109
*/
110
boolean state;
111
112
/**
113
* The check box group.
114
* This field can be null indicating that the checkbox
115
* is not a group checkbox.
116
* @serial
117
* @see #getCheckboxGroup()
118
* @see #setCheckboxGroup(CheckboxGroup)
119
*/
120
CheckboxGroup group;
121
122
transient ItemListener itemListener;
123
124
private static final String base = "checkbox";
125
private static int nameCounter = 0;
126
127
/**
128
* Use serialVersionUID from JDK 1.1 for interoperability.
129
*/
130
@Serial
131
private static final long serialVersionUID = 7270714317450821763L;
132
133
/**
134
* Helper function for setState and CheckboxGroup.setSelectedCheckbox
135
* Should remain package-private.
136
*/
137
void setStateInternal(boolean state) {
138
this.state = state;
139
CheckboxPeer peer = (CheckboxPeer)this.peer;
140
if (peer != null) {
141
peer.setState(state);
142
}
143
}
144
145
/**
146
* Creates a check box with an empty string for its label.
147
* The state of this check box is set to "off," and it is not
148
* part of any check box group.
149
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
150
* returns true
151
* @see java.awt.GraphicsEnvironment#isHeadless
152
*/
153
public Checkbox() throws HeadlessException {
154
this("", false, null);
155
}
156
157
/**
158
* Creates a check box with the specified label. The state
159
* of this check box is set to "off," and it is not part of
160
* any check box group.
161
*
162
* @param label a string label for this check box,
163
* or {@code null} for no label.
164
* @exception HeadlessException if
165
* {@code GraphicsEnvironment.isHeadless}
166
* returns {@code true}
167
* @see java.awt.GraphicsEnvironment#isHeadless
168
*/
169
public Checkbox(String label) throws HeadlessException {
170
this(label, false, null);
171
}
172
173
/**
174
* Creates a check box with the specified label
175
* and sets the specified state.
176
* This check box is not part of any check box group.
177
*
178
* @param label a string label for this check box,
179
* or {@code null} for no label
180
* @param state the initial state of this check box
181
* @exception HeadlessException if
182
* {@code GraphicsEnvironment.isHeadless}
183
* returns {@code true}
184
* @see java.awt.GraphicsEnvironment#isHeadless
185
*/
186
public Checkbox(String label, boolean state) throws HeadlessException {
187
this(label, state, null);
188
}
189
190
/**
191
* Constructs a Checkbox with the specified label, set to the
192
* specified state, and in the specified check box group.
193
*
194
* @param label a string label for this check box,
195
* or {@code null} for no label.
196
* @param state the initial state of this check box.
197
* @param group a check box group for this check box,
198
* or {@code null} for no group.
199
* @exception HeadlessException if
200
* {@code GraphicsEnvironment.isHeadless}
201
* returns {@code true}
202
* @see java.awt.GraphicsEnvironment#isHeadless
203
* @since 1.1
204
*/
205
public Checkbox(String label, boolean state, CheckboxGroup group)
206
throws HeadlessException {
207
GraphicsEnvironment.checkHeadless();
208
this.label = label;
209
this.state = state;
210
this.group = group;
211
if (state && (group != null)) {
212
group.setSelectedCheckbox(this);
213
}
214
}
215
216
/**
217
* Creates a check box with the specified label, in the specified
218
* check box group, and set to the specified state.
219
*
220
* @param label a string label for this check box,
221
* or {@code null} for no label.
222
* @param group a check box group for this check box,
223
* or {@code null} for no group.
224
* @param state the initial state of this check box.
225
* @exception HeadlessException if
226
* {@code GraphicsEnvironment.isHeadless}
227
* returns {@code true}
228
* @see java.awt.GraphicsEnvironment#isHeadless
229
* @since 1.1
230
*/
231
public Checkbox(String label, CheckboxGroup group, boolean state)
232
throws HeadlessException {
233
this(label, state, group);
234
}
235
236
/**
237
* Constructs a name for this component. Called by
238
* {@code getName} when the name is {@code null}.
239
*
240
* @return a name for this component
241
*/
242
String constructComponentName() {
243
synchronized (Checkbox.class) {
244
return base + nameCounter++;
245
}
246
}
247
248
/**
249
* Creates the peer of the Checkbox. The peer allows you to change the
250
* look of the Checkbox without changing its functionality.
251
*
252
* @see java.awt.Component#getToolkit()
253
*/
254
public void addNotify() {
255
synchronized (getTreeLock()) {
256
if (peer == null)
257
peer = getComponentFactory().createCheckbox(this);
258
super.addNotify();
259
}
260
}
261
262
/**
263
* Gets the label of this check box.
264
*
265
* @return the label of this check box, or {@code null}
266
* if this check box has no label.
267
* @see #setLabel(String)
268
*/
269
public String getLabel() {
270
return label;
271
}
272
273
/**
274
* Sets this check box's label to be the string argument.
275
*
276
* @param label a string to set as the new label, or
277
* {@code null} for no label.
278
* @see #getLabel
279
*/
280
public void setLabel(String label) {
281
boolean testvalid = false;
282
283
synchronized (this) {
284
if (label != this.label && (this.label == null ||
285
!this.label.equals(label))) {
286
this.label = label;
287
CheckboxPeer peer = (CheckboxPeer)this.peer;
288
if (peer != null) {
289
peer.setLabel(label);
290
}
291
testvalid = true;
292
}
293
}
294
295
// This could change the preferred size of the Component.
296
if (testvalid) {
297
invalidateIfValid();
298
}
299
}
300
301
/**
302
* Determines whether this check box is in the "on" or "off" state.
303
* The boolean value {@code true} indicates the "on" state,
304
* and {@code false} indicates the "off" state.
305
*
306
* @return the state of this check box, as a boolean value
307
* @see #setState
308
*/
309
public boolean getState() {
310
return state;
311
}
312
313
/**
314
* Sets the state of this check box to the specified state.
315
* The boolean value {@code true} indicates the "on" state,
316
* and {@code false} indicates the "off" state.
317
*
318
* <p>Note that this method should be primarily used to
319
* initialize the state of the checkbox. Programmatically
320
* setting the state of the checkbox will <i>not</i> trigger
321
* an {@code ItemEvent}. The only way to trigger an
322
* {@code ItemEvent} is by user interaction.
323
*
324
* @param state the boolean state of the check box
325
* @see #getState
326
*/
327
public void setState(boolean state) {
328
/* Cannot hold check box lock when calling group.setSelectedCheckbox. */
329
CheckboxGroup group = this.group;
330
if (group != null) {
331
if (state) {
332
group.setSelectedCheckbox(this);
333
} else if (group.getSelectedCheckbox() == this) {
334
state = true;
335
}
336
}
337
setStateInternal(state);
338
}
339
340
/**
341
* Returns an array (length 1) containing the checkbox
342
* label or null if the checkbox is not selected.
343
* @see ItemSelectable
344
*/
345
public Object[] getSelectedObjects() {
346
if (state) {
347
Object[] items = new Object[1];
348
items[0] = label;
349
return items;
350
}
351
return null;
352
}
353
354
/**
355
* Determines this check box's group.
356
* @return this check box's group, or {@code null}
357
* if the check box is not part of a check box group.
358
* @see #setCheckboxGroup(CheckboxGroup)
359
*/
360
public CheckboxGroup getCheckboxGroup() {
361
return group;
362
}
363
364
/**
365
* Sets this check box's group to the specified check box group.
366
* If this check box is already in a different check box group,
367
* it is first taken out of that group.
368
* <p>
369
* If the state of this check box is {@code true} and the new
370
* group already has a check box selected, this check box's state
371
* is changed to {@code false}. If the state of this check
372
* box is {@code true} and the new group has no check box
373
* selected, this check box becomes the selected checkbox for
374
* the new group and its state is {@code true}.
375
*
376
* @param g the new check box group, or {@code null}
377
* to remove this check box from any check box group
378
* @see #getCheckboxGroup
379
*/
380
public void setCheckboxGroup(CheckboxGroup g) {
381
CheckboxGroup oldGroup;
382
boolean oldState;
383
384
/* Do nothing if this check box has already belonged
385
* to the check box group g.
386
*/
387
if (this.group == g) {
388
return;
389
}
390
391
synchronized (this) {
392
oldGroup = this.group;
393
oldState = getState();
394
395
this.group = g;
396
CheckboxPeer peer = (CheckboxPeer)this.peer;
397
if (peer != null) {
398
peer.setCheckboxGroup(g);
399
}
400
if (this.group != null && getState()) {
401
if (this.group.getSelectedCheckbox() != null) {
402
setState(false);
403
} else {
404
this.group.setSelectedCheckbox(this);
405
}
406
}
407
}
408
409
/* Locking check box below could cause deadlock with
410
* CheckboxGroup's setSelectedCheckbox method.
411
*
412
* Fix for 4726853 by [email protected]
413
* Here we should check if this check box was selected
414
* in the previous group and set selected check box to
415
* null for that group if so.
416
*/
417
if (oldGroup != null && oldState) {
418
oldGroup.setSelectedCheckbox(null);
419
}
420
}
421
422
/**
423
* Adds the specified item listener to receive item events from
424
* this check box. Item events are sent to listeners in response
425
* to user input, but not in response to calls to setState().
426
* If l is null, no exception is thrown and no action is performed.
427
* <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
428
* >AWT Threading Issues</a> for details on AWT's threading model.
429
*
430
* @param l the item listener
431
* @see #removeItemListener
432
* @see #getItemListeners
433
* @see #setState
434
* @see java.awt.event.ItemEvent
435
* @see java.awt.event.ItemListener
436
* @since 1.1
437
*/
438
public synchronized void addItemListener(ItemListener l) {
439
if (l == null) {
440
return;
441
}
442
itemListener = AWTEventMulticaster.add(itemListener, l);
443
newEventsOnly = true;
444
}
445
446
/**
447
* Removes the specified item listener so that the item listener
448
* no longer receives item events from this check box.
449
* If l is null, no exception is thrown and no action is performed.
450
* <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
451
* >AWT Threading Issues</a> for details on AWT's threading model.
452
*
453
* @param l the item listener
454
* @see #addItemListener
455
* @see #getItemListeners
456
* @see java.awt.event.ItemEvent
457
* @see java.awt.event.ItemListener
458
* @since 1.1
459
*/
460
public synchronized void removeItemListener(ItemListener l) {
461
if (l == null) {
462
return;
463
}
464
itemListener = AWTEventMulticaster.remove(itemListener, l);
465
}
466
467
/**
468
* Returns an array of all the item listeners
469
* registered on this checkbox.
470
*
471
* @return all of this checkbox's {@code ItemListener}s
472
* or an empty array if no item
473
* listeners are currently registered
474
*
475
* @see #addItemListener
476
* @see #removeItemListener
477
* @see java.awt.event.ItemEvent
478
* @see java.awt.event.ItemListener
479
* @since 1.4
480
*/
481
public synchronized ItemListener[] getItemListeners() {
482
return getListeners(ItemListener.class);
483
}
484
485
/**
486
* Returns an array of all the objects currently registered
487
* as <code><em>Foo</em>Listener</code>s
488
* upon this {@code Checkbox}.
489
* <code><em>Foo</em>Listener</code>s are registered using the
490
* <code>add<em>Foo</em>Listener</code> method.
491
*
492
* <p>
493
* You can specify the {@code listenerType} argument
494
* with a class literal, such as
495
* <code><em>Foo</em>Listener.class</code>.
496
* For example, you can query a
497
* {@code Checkbox c}
498
* for its item listeners with the following code:
499
*
500
* <pre>ItemListener[] ils = (ItemListener[])(c.getListeners(ItemListener.class));</pre>
501
*
502
* If no such listeners exist, this method returns an empty array.
503
*
504
* @param listenerType the type of listeners requested; this parameter
505
* should specify an interface that descends from
506
* {@code java.util.EventListener}
507
* @return an array of all objects registered as
508
* <code><em>Foo</em>Listener</code>s on this checkbox,
509
* or an empty array if no such
510
* listeners have been added
511
* @exception ClassCastException if {@code listenerType}
512
* doesn't specify a class or interface that implements
513
* {@code java.util.EventListener}
514
*
515
* @see #getItemListeners
516
* @since 1.3
517
*/
518
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
519
EventListener l = null;
520
if (listenerType == ItemListener.class) {
521
l = itemListener;
522
} else {
523
return super.getListeners(listenerType);
524
}
525
return AWTEventMulticaster.getListeners(l, listenerType);
526
}
527
528
// REMIND: remove when filtering is done at lower level
529
boolean eventEnabled(AWTEvent e) {
530
if (e.id == ItemEvent.ITEM_STATE_CHANGED) {
531
if ((eventMask & AWTEvent.ITEM_EVENT_MASK) != 0 ||
532
itemListener != null) {
533
return true;
534
}
535
return false;
536
}
537
return super.eventEnabled(e);
538
}
539
540
/**
541
* Processes events on this check box.
542
* If the event is an instance of {@code ItemEvent},
543
* this method invokes the {@code processItemEvent} method.
544
* Otherwise, it calls its superclass's {@code processEvent} method.
545
* <p>Note that if the event parameter is {@code null}
546
* the behavior is unspecified and may result in an
547
* exception.
548
*
549
* @param e the event
550
* @see java.awt.event.ItemEvent
551
* @see #processItemEvent
552
* @since 1.1
553
*/
554
protected void processEvent(AWTEvent e) {
555
if (e instanceof ItemEvent) {
556
processItemEvent((ItemEvent)e);
557
return;
558
}
559
super.processEvent(e);
560
}
561
562
/**
563
* Processes item events occurring on this check box by
564
* dispatching them to any registered
565
* {@code ItemListener} objects.
566
* <p>
567
* This method is not called unless item events are
568
* enabled for this component. Item events are enabled
569
* when one of the following occurs:
570
* <ul>
571
* <li>An {@code ItemListener} object is registered
572
* via {@code addItemListener}.
573
* <li>Item events are enabled via {@code enableEvents}.
574
* </ul>
575
* <p>Note that if the event parameter is {@code null}
576
* the behavior is unspecified and may result in an
577
* exception.
578
*
579
* @param e the item event
580
* @see java.awt.event.ItemEvent
581
* @see java.awt.event.ItemListener
582
* @see #addItemListener
583
* @see java.awt.Component#enableEvents
584
* @since 1.1
585
*/
586
protected void processItemEvent(ItemEvent e) {
587
ItemListener listener = itemListener;
588
if (listener != null) {
589
listener.itemStateChanged(e);
590
}
591
}
592
593
/**
594
* Returns a string representing the state of this {@code Checkbox}.
595
* This method is intended to be used only for debugging purposes, and the
596
* content and format of the returned string may vary between
597
* implementations. The returned string may be empty but may not be
598
* {@code null}.
599
*
600
* @return the parameter string of this check box
601
*/
602
protected String paramString() {
603
String str = super.paramString();
604
String label = this.label;
605
if (label != null) {
606
str += ",label=" + label;
607
}
608
return str + ",state=" + state;
609
}
610
611
612
/* Serialization support.
613
*/
614
615
/**
616
* Serialized data version.
617
* @serial
618
*/
619
private int checkboxSerializedDataVersion = 1;
620
621
/**
622
* Writes default serializable fields to stream. Writes
623
* a list of serializable {@code ItemListeners}
624
* as optional data. The non-serializable
625
* {@code ItemListeners} are detected and
626
* no attempt is made to serialize them.
627
*
628
* @param s the {@code ObjectOutputStream} to write
629
* @throws IOException if an I/O error occurs
630
* @serialData {@code null} terminated sequence of 0
631
* or more pairs; the pair consists of a {@code String}
632
* and an {@code Object}; the {@code String} indicates
633
* the type of object and is one of the following:
634
* {@code itemListenerK} indicating an
635
* {@code ItemListener} object
636
*
637
* @see AWTEventMulticaster#save(ObjectOutputStream, String, EventListener)
638
* @see java.awt.Component#itemListenerK
639
* @see #readObject(ObjectInputStream)
640
*/
641
@Serial
642
private void writeObject(ObjectOutputStream s)
643
throws java.io.IOException
644
{
645
s.defaultWriteObject();
646
647
AWTEventMulticaster.save(s, itemListenerK, itemListener);
648
s.writeObject(null);
649
}
650
651
/**
652
* Reads the {@code ObjectInputStream} and if it
653
* isn't {@code null} adds a listener to receive
654
* item events fired by the {@code Checkbox}.
655
* Unrecognized keys or values will be ignored.
656
*
657
* @param s the {@code ObjectInputStream} to read
658
* @throws ClassNotFoundException if the class of a serialized object could
659
* not be found
660
* @throws IOException if an I/O error occurs
661
* @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
662
* returns {@code true}
663
* @serial
664
* @see #removeItemListener(ItemListener)
665
* @see #addItemListener(ItemListener)
666
* @see java.awt.GraphicsEnvironment#isHeadless
667
* @see #writeObject(ObjectOutputStream)
668
*/
669
@Serial
670
private void readObject(ObjectInputStream s)
671
throws ClassNotFoundException, IOException, HeadlessException
672
{
673
GraphicsEnvironment.checkHeadless();
674
s.defaultReadObject();
675
676
Object keyOrNull;
677
while(null != (keyOrNull = s.readObject())) {
678
String key = ((String)keyOrNull).intern();
679
680
if (itemListenerK == key)
681
addItemListener((ItemListener)(s.readObject()));
682
683
else // skip value for unrecognized key
684
s.readObject();
685
}
686
}
687
688
/**
689
* Initialize JNI field and method ids
690
*/
691
private static native void initIDs();
692
693
694
/////////////////
695
// Accessibility support
696
////////////////
697
698
699
/**
700
* Gets the AccessibleContext associated with this Checkbox.
701
* For checkboxes, the AccessibleContext takes the form of an
702
* AccessibleAWTCheckbox.
703
* A new AccessibleAWTCheckbox is created if necessary.
704
*
705
* @return an AccessibleAWTCheckbox that serves as the
706
* AccessibleContext of this Checkbox
707
* @since 1.3
708
*/
709
public AccessibleContext getAccessibleContext() {
710
if (accessibleContext == null) {
711
accessibleContext = new AccessibleAWTCheckbox();
712
}
713
return accessibleContext;
714
}
715
716
/**
717
* This class implements accessibility support for the
718
* {@code Checkbox} class. It provides an implementation of the
719
* Java Accessibility API appropriate to checkbox user-interface elements.
720
* @since 1.3
721
*/
722
protected class AccessibleAWTCheckbox extends AccessibleAWTComponent
723
implements ItemListener, AccessibleAction, AccessibleValue
724
{
725
/**
726
* Use serialVersionUID from JDK 1.3 for interoperability.
727
*/
728
@Serial
729
private static final long serialVersionUID = 7881579233144754107L;
730
731
/**
732
* Constructor for {@code AccessibleAWTCheckbox}
733
*/
734
public AccessibleAWTCheckbox() {
735
super();
736
Checkbox.this.addItemListener(this);
737
}
738
739
/**
740
* Fire accessible property change events when the state of the
741
* toggle button changes.
742
*/
743
public void itemStateChanged(ItemEvent e) {
744
Checkbox cb = (Checkbox) e.getSource();
745
if (Checkbox.this.accessibleContext != null) {
746
if (cb.getState()) {
747
Checkbox.this.accessibleContext.firePropertyChange(
748
AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
749
null, AccessibleState.CHECKED);
750
} else {
751
Checkbox.this.accessibleContext.firePropertyChange(
752
AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
753
AccessibleState.CHECKED, null);
754
}
755
}
756
}
757
758
/**
759
* Get the AccessibleAction associated with this object. In the
760
* implementation of the Java Accessibility API for this class,
761
* return this object, which is responsible for implementing the
762
* AccessibleAction interface on behalf of itself.
763
*
764
* @return this object
765
*/
766
public AccessibleAction getAccessibleAction() {
767
return this;
768
}
769
770
/**
771
* Get the AccessibleValue associated with this object. In the
772
* implementation of the Java Accessibility API for this class,
773
* return this object, which is responsible for implementing the
774
* AccessibleValue interface on behalf of itself.
775
*
776
* @return this object
777
*/
778
public AccessibleValue getAccessibleValue() {
779
return this;
780
}
781
782
/**
783
* Returns the number of Actions available in this object.
784
* If there is more than one, the first one is the "default"
785
* action.
786
*
787
* @return the number of Actions in this object
788
*/
789
public int getAccessibleActionCount() {
790
return 0; // To be fully implemented in a future release
791
}
792
793
/**
794
* Return a description of the specified action of the object.
795
*
796
* @param i zero-based index of the actions
797
*/
798
public String getAccessibleActionDescription(int i) {
799
return null; // To be fully implemented in a future release
800
}
801
802
/**
803
* Perform the specified Action on the object
804
*
805
* @param i zero-based index of actions
806
* @return true if the action was performed; else false.
807
*/
808
public boolean doAccessibleAction(int i) {
809
return false; // To be fully implemented in a future release
810
}
811
812
/**
813
* Get the value of this object as a Number. If the value has not been
814
* set, the return value will be null.
815
*
816
* @return value of the object
817
* @see #setCurrentAccessibleValue
818
*/
819
public Number getCurrentAccessibleValue() {
820
return null; // To be fully implemented in a future release
821
}
822
823
/**
824
* Set the value of this object as a Number.
825
*
826
* @return True if the value was set; else False
827
* @see #getCurrentAccessibleValue
828
*/
829
public boolean setCurrentAccessibleValue(Number n) {
830
return false; // To be fully implemented in a future release
831
}
832
833
/**
834
* Get the minimum value of this object as a Number.
835
*
836
* @return Minimum value of the object; null if this object does not
837
* have a minimum value
838
* @see #getMaximumAccessibleValue
839
*/
840
public Number getMinimumAccessibleValue() {
841
return null; // To be fully implemented in a future release
842
}
843
844
/**
845
* Get the maximum value of this object as a Number.
846
*
847
* @return Maximum value of the object; null if this object does not
848
* have a maximum value
849
* @see #getMinimumAccessibleValue
850
*/
851
public Number getMaximumAccessibleValue() {
852
return null; // To be fully implemented in a future release
853
}
854
855
/**
856
* Get the role of this object.
857
*
858
* @return an instance of AccessibleRole describing the role of
859
* the object
860
* @see AccessibleRole
861
*/
862
public AccessibleRole getAccessibleRole() {
863
return AccessibleRole.CHECK_BOX;
864
}
865
866
/**
867
* Get the state set of this object.
868
*
869
* @return an instance of AccessibleState containing the current state
870
* of the object
871
* @see AccessibleState
872
*/
873
public AccessibleStateSet getAccessibleStateSet() {
874
AccessibleStateSet states = super.getAccessibleStateSet();
875
if (getState()) {
876
states.add(AccessibleState.CHECKED);
877
}
878
return states;
879
}
880
881
882
} // inner class AccessibleAWTCheckbox
883
884
}
885
886