Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.desktop/share/classes/java/awt/Choice.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.ChoicePeer;
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
import java.util.Vector;
37
38
import javax.accessibility.Accessible;
39
import javax.accessibility.AccessibleAction;
40
import javax.accessibility.AccessibleContext;
41
import javax.accessibility.AccessibleRole;
42
43
/**
44
* The {@code Choice} class presents a pop-up menu of choices.
45
* The current choice is displayed as the title of the menu.
46
* <p>
47
* The following code example produces a pop-up menu:
48
*
49
* <hr><blockquote><pre>
50
* Choice ColorChooser = new Choice();
51
* ColorChooser.add("Green");
52
* ColorChooser.add("Red");
53
* ColorChooser.add("Blue");
54
* </pre></blockquote><hr>
55
* <p>
56
* After this choice menu has been added to a panel,
57
* it appears as follows in its normal state:
58
* <p>
59
* <img src="doc-files/Choice-1.gif" alt="The following text describes the
60
* graphic" style="margin: 7px 10px;">
61
* <p>
62
* In the picture, {@code "Green"} is the current choice.
63
* Pushing the mouse button down on the object causes a menu to
64
* appear with the current choice highlighted.
65
* <p>
66
* Some native platforms do not support arbitrary resizing of
67
* {@code Choice} components and the behavior of
68
* {@code setSize()/getSize()} is bound by
69
* such limitations.
70
* Native GUI {@code Choice} components' size are often bound by such
71
* attributes as font size and length of items contained within
72
* the {@code Choice}.
73
*
74
* @author Sami Shaio
75
* @author Arthur van Hoff
76
* @since 1.0
77
*/
78
public class Choice extends Component implements ItemSelectable, Accessible {
79
/**
80
* The items for the {@code Choice}.
81
* This can be a {@code null} value.
82
* @serial
83
* @see #add(String)
84
* @see #addItem(String)
85
* @see #getItem(int)
86
* @see #getItemCount()
87
* @see #insert(String, int)
88
* @see #remove(String)
89
*/
90
Vector<String> pItems;
91
92
/**
93
* The index of the current choice for this {@code Choice}
94
* or -1 if nothing is selected.
95
* @serial
96
* @see #getSelectedItem()
97
* @see #select(int)
98
*/
99
int selectedIndex = -1;
100
101
transient ItemListener itemListener;
102
103
private static final String base = "choice";
104
private static int nameCounter = 0;
105
106
/**
107
* Use serialVersionUID from JDK 1.1 for interoperability.
108
*/
109
@Serial
110
private static final long serialVersionUID = -4075310674757313071L;
111
112
static {
113
/* ensure that the necessary native libraries are loaded */
114
Toolkit.loadLibraries();
115
/* initialize JNI field and method ids */
116
if (!GraphicsEnvironment.isHeadless()) {
117
initIDs();
118
}
119
}
120
121
/**
122
* Creates a new choice menu. The menu initially has no items in it.
123
* <p>
124
* By default, the first item added to the choice menu becomes the
125
* selected item, until a different selection is made by the user
126
* by calling one of the {@code select} methods.
127
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
128
* returns true
129
* @see java.awt.GraphicsEnvironment#isHeadless
130
* @see #select(int)
131
* @see #select(java.lang.String)
132
*/
133
public Choice() throws HeadlessException {
134
GraphicsEnvironment.checkHeadless();
135
pItems = new Vector<>();
136
}
137
138
/**
139
* Constructs a name for this component. Called by
140
* {@code getName} when the name is {@code null}.
141
*/
142
String constructComponentName() {
143
synchronized (Choice.class) {
144
return base + nameCounter++;
145
}
146
}
147
148
/**
149
* Creates the {@code Choice}'s peer. This peer allows us
150
* to change the look
151
* of the {@code Choice} without changing its functionality.
152
* @see java.awt.Component#getToolkit()
153
*/
154
public void addNotify() {
155
synchronized (getTreeLock()) {
156
if (peer == null)
157
peer = getComponentFactory().createChoice(this);
158
super.addNotify();
159
}
160
}
161
162
/**
163
* Returns the number of items in this {@code Choice} menu.
164
*
165
* @return the number of items in this {@code Choice} menu
166
* @see #getItem
167
* @since 1.1
168
*/
169
public int getItemCount() {
170
return countItems();
171
}
172
173
/**
174
* Returns the number of items in this {@code Choice} menu.
175
*
176
* @return the number of items in this {@code Choice} menu
177
* @deprecated As of JDK version 1.1,
178
* replaced by {@code getItemCount()}.
179
*/
180
@Deprecated
181
public int countItems() {
182
return pItems.size();
183
}
184
185
/**
186
* Gets the string at the specified index in this
187
* {@code Choice} menu.
188
*
189
* @param index the index at which to begin
190
* @return the item at the specified index
191
* @see #getItemCount
192
*/
193
public String getItem(int index) {
194
return getItemImpl(index);
195
}
196
197
/*
198
* This is called by the native code, so client code can't
199
* be called on the toolkit thread.
200
*/
201
final String getItemImpl(int index) {
202
return pItems.elementAt(index);
203
}
204
205
/**
206
* Adds an item to this {@code Choice} menu.
207
* @param item the item to be added
208
* @exception NullPointerException if the item's value is
209
* {@code null}
210
* @since 1.1
211
*/
212
public void add(String item) {
213
addItem(item);
214
}
215
216
/**
217
* Obsolete as of Java 2 platform v1.1. Please use the
218
* {@code add} method instead.
219
* <p>
220
* Adds an item to this {@code Choice} menu.
221
* @param item the item to be added
222
* @exception NullPointerException if the item's value is equal to
223
* {@code null}
224
*/
225
public void addItem(String item) {
226
synchronized (this) {
227
insertNoInvalidate(item, pItems.size());
228
}
229
230
// This could change the preferred size of the Component.
231
invalidateIfValid();
232
}
233
234
/**
235
* Inserts an item to this {@code Choice},
236
* but does not invalidate the {@code Choice}.
237
* Client methods must provide their own synchronization before
238
* invoking this method.
239
* @param item the item to be added
240
* @param index the new item position
241
* @exception NullPointerException if the item's value is equal to
242
* {@code null}
243
*/
244
private void insertNoInvalidate(String item, int index) {
245
if (item == null) {
246
throw new
247
NullPointerException("cannot add null item to Choice");
248
}
249
pItems.insertElementAt(item, index);
250
ChoicePeer peer = (ChoicePeer)this.peer;
251
if (peer != null) {
252
peer.add(item, index);
253
}
254
// no selection or selection shifted up
255
if (selectedIndex < 0 || selectedIndex >= index) {
256
select(0);
257
}
258
}
259
260
261
/**
262
* Inserts the item into this choice at the specified position.
263
* Existing items at an index greater than or equal to
264
* {@code index} are shifted up by one to accommodate
265
* the new item. If {@code index} is greater than or
266
* equal to the number of items in this choice,
267
* {@code item} is added to the end of this choice.
268
* <p>
269
* If the item is the first one being added to the choice,
270
* then the item becomes selected. Otherwise, if the
271
* selected item was one of the items shifted, the first
272
* item in the choice becomes the selected item. If the
273
* selected item was no among those shifted, it remains
274
* the selected item.
275
* @param item the non-{@code null} item to be inserted
276
* @param index the position at which the item should be inserted
277
* @exception IllegalArgumentException if index is less than 0
278
*/
279
public void insert(String item, int index) {
280
synchronized (this) {
281
if (index < 0) {
282
throw new IllegalArgumentException("index less than zero.");
283
}
284
/* if the index greater than item count, add item to the end */
285
index = Math.min(index, pItems.size());
286
287
insertNoInvalidate(item, index);
288
}
289
290
// This could change the preferred size of the Component.
291
invalidateIfValid();
292
}
293
294
/**
295
* Removes the first occurrence of {@code item}
296
* from the {@code Choice} menu. If the item
297
* being removed is the currently selected item,
298
* then the first item in the choice becomes the
299
* selected item. Otherwise, the currently selected
300
* item remains selected (and the selected index is
301
* updated accordingly).
302
* @param item the item to remove from this {@code Choice} menu
303
* @exception IllegalArgumentException if the item doesn't
304
* exist in the choice menu
305
* @since 1.1
306
*/
307
public void remove(String item) {
308
synchronized (this) {
309
int index = pItems.indexOf(item);
310
if (index < 0) {
311
throw new IllegalArgumentException("item " + item +
312
" not found in choice");
313
} else {
314
removeNoInvalidate(index);
315
}
316
}
317
318
// This could change the preferred size of the Component.
319
invalidateIfValid();
320
}
321
322
/**
323
* Removes an item from the choice menu
324
* at the specified position. If the item
325
* being removed is the currently selected item,
326
* then the first item in the choice becomes the
327
* selected item. Otherwise, the currently selected
328
* item remains selected (and the selected index is
329
* updated accordingly).
330
* @param position the position of the item
331
* @throws IndexOutOfBoundsException if the specified
332
* position is out of bounds
333
* @since 1.1
334
*/
335
public void remove(int position) {
336
synchronized (this) {
337
removeNoInvalidate(position);
338
}
339
340
// This could change the preferred size of the Component.
341
invalidateIfValid();
342
}
343
344
/**
345
* Removes an item from the {@code Choice} at the
346
* specified position, but does not invalidate the {@code Choice}.
347
* Client methods must provide their
348
* own synchronization before invoking this method.
349
* @param position the position of the item
350
*/
351
private void removeNoInvalidate(int position) {
352
pItems.removeElementAt(position);
353
ChoicePeer peer = (ChoicePeer)this.peer;
354
if (peer != null) {
355
peer.remove(position);
356
}
357
/* Adjust selectedIndex if selected item was removed. */
358
if (pItems.size() == 0) {
359
selectedIndex = -1;
360
} else if (selectedIndex == position) {
361
select(0);
362
} else if (selectedIndex > position) {
363
select(selectedIndex-1);
364
}
365
}
366
367
368
/**
369
* Removes all items from the choice menu.
370
* @see #remove
371
* @since 1.1
372
*/
373
public void removeAll() {
374
synchronized (this) {
375
if (peer != null) {
376
((ChoicePeer)peer).removeAll();
377
}
378
pItems.removeAllElements();
379
selectedIndex = -1;
380
}
381
382
// This could change the preferred size of the Component.
383
invalidateIfValid();
384
}
385
386
/**
387
* Gets a representation of the current choice as a string.
388
* @return a string representation of the currently
389
* selected item in this choice menu
390
* @see #getSelectedIndex
391
*/
392
public synchronized String getSelectedItem() {
393
return (selectedIndex >= 0) ? getItem(selectedIndex) : null;
394
}
395
396
/**
397
* Returns an array (length 1) containing the currently selected
398
* item. If this choice has no items, returns {@code null}.
399
* @see ItemSelectable
400
*/
401
public synchronized Object[] getSelectedObjects() {
402
if (selectedIndex >= 0) {
403
Object[] items = new Object[1];
404
items[0] = getItem(selectedIndex);
405
return items;
406
}
407
return null;
408
}
409
410
/**
411
* Returns the index of the currently selected item.
412
* If nothing is selected, returns -1.
413
*
414
* @return the index of the currently selected item, or -1 if nothing
415
* is currently selected
416
* @see #getSelectedItem
417
*/
418
public int getSelectedIndex() {
419
return selectedIndex;
420
}
421
422
/**
423
* Sets the selected item in this {@code Choice} menu to be the
424
* item at the specified position.
425
*
426
* <p>Note that this method should be primarily used to
427
* initially select an item in this component.
428
* Programmatically calling this method will <i>not</i> trigger
429
* an {@code ItemEvent}. The only way to trigger an
430
* {@code ItemEvent} is by user interaction.
431
*
432
* @param pos the position of the selected item
433
* @exception IllegalArgumentException if the specified
434
* position is greater than the
435
* number of items or less than zero
436
* @see #getSelectedItem
437
* @see #getSelectedIndex
438
*/
439
public synchronized void select(int pos) {
440
if ((pos >= pItems.size()) || (pos < 0)) {
441
throw new IllegalArgumentException("illegal Choice item position: " + pos);
442
}
443
if (pItems.size() > 0) {
444
selectedIndex = pos;
445
ChoicePeer peer = (ChoicePeer)this.peer;
446
if (peer != null) {
447
peer.select(pos);
448
}
449
}
450
}
451
452
/**
453
* Sets the selected item in this {@code Choice} menu
454
* to be the item whose name is equal to the specified string.
455
* If more than one item matches (is equal to) the specified string,
456
* the one with the smallest index is selected.
457
*
458
* <p>Note that this method should be primarily used to
459
* initially select an item in this component.
460
* Programmatically calling this method will <i>not</i> trigger
461
* an {@code ItemEvent}. The only way to trigger an
462
* {@code ItemEvent} is by user interaction.
463
*
464
* @param str the specified string
465
* @see #getSelectedItem
466
* @see #getSelectedIndex
467
*/
468
public synchronized void select(String str) {
469
int index = pItems.indexOf(str);
470
if (index >= 0) {
471
select(index);
472
}
473
}
474
475
/**
476
* Adds the specified item listener to receive item events from
477
* this {@code Choice} menu. Item events are sent in response
478
* to user input, but not in response to calls to {@code select}.
479
* If l is {@code null}, no exception is thrown and no action
480
* is performed.
481
* <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
482
* >AWT Threading Issues</a> for details on AWT's threading model.
483
* @param l the item listener
484
* @see #removeItemListener
485
* @see #getItemListeners
486
* @see #select
487
* @see java.awt.event.ItemEvent
488
* @see java.awt.event.ItemListener
489
* @since 1.1
490
*/
491
public synchronized void addItemListener(ItemListener l) {
492
if (l == null) {
493
return;
494
}
495
itemListener = AWTEventMulticaster.add(itemListener, l);
496
newEventsOnly = true;
497
}
498
499
/**
500
* Removes the specified item listener so that it no longer receives
501
* item events from this {@code Choice} menu.
502
* If l is {@code null}, no exception is thrown and no
503
* action is performed.
504
* <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
505
* >AWT Threading Issues</a> for details on AWT's threading model.
506
* @param l the item listener
507
* @see #addItemListener
508
* @see #getItemListeners
509
* @see java.awt.event.ItemEvent
510
* @see java.awt.event.ItemListener
511
* @since 1.1
512
*/
513
public synchronized void removeItemListener(ItemListener l) {
514
if (l == null) {
515
return;
516
}
517
itemListener = AWTEventMulticaster.remove(itemListener, l);
518
}
519
520
/**
521
* Returns an array of all the item listeners
522
* registered on this choice.
523
*
524
* @return all of this choice's {@code ItemListener}s
525
* or an empty array if no item
526
* listeners are currently registered
527
*
528
* @see #addItemListener
529
* @see #removeItemListener
530
* @see java.awt.event.ItemEvent
531
* @see java.awt.event.ItemListener
532
* @since 1.4
533
*/
534
public synchronized ItemListener[] getItemListeners() {
535
return getListeners(ItemListener.class);
536
}
537
538
/**
539
* Returns an array of all the objects currently registered
540
* as <code><em>Foo</em>Listener</code>s
541
* upon this {@code Choice}.
542
* <code><em>Foo</em>Listener</code>s are registered using the
543
* <code>add<em>Foo</em>Listener</code> method.
544
*
545
* <p>
546
* You can specify the {@code listenerType} argument
547
* with a class literal, such as
548
* <code><em>Foo</em>Listener.class</code>.
549
* For example, you can query a
550
* {@code Choice c}
551
* for its item listeners with the following code:
552
*
553
* <pre>ItemListener[] ils = (ItemListener[])(c.getListeners(ItemListener.class));</pre>
554
*
555
* If no such listeners exist, this method returns an empty array.
556
*
557
* @param listenerType the type of listeners requested; this parameter
558
* should specify an interface that descends from
559
* {@code java.util.EventListener}
560
* @return an array of all objects registered as
561
* <code><em>Foo</em>Listener</code>s on this choice,
562
* or an empty array if no such
563
* listeners have been added
564
* @exception ClassCastException if {@code listenerType}
565
* doesn't specify a class or interface that implements
566
* {@code java.util.EventListener}
567
*
568
* @see #getItemListeners
569
* @since 1.3
570
*/
571
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
572
EventListener l = null;
573
if (listenerType == ItemListener.class) {
574
l = itemListener;
575
} else {
576
return super.getListeners(listenerType);
577
}
578
return AWTEventMulticaster.getListeners(l, listenerType);
579
}
580
581
// REMIND: remove when filtering is done at lower level
582
boolean eventEnabled(AWTEvent e) {
583
if (e.id == ItemEvent.ITEM_STATE_CHANGED) {
584
if ((eventMask & AWTEvent.ITEM_EVENT_MASK) != 0 ||
585
itemListener != null) {
586
return true;
587
}
588
return false;
589
}
590
return super.eventEnabled(e);
591
}
592
593
/**
594
* Processes events on this choice. If the event is an
595
* instance of {@code ItemEvent}, it invokes the
596
* {@code processItemEvent} method. Otherwise, it calls its
597
* superclass's {@code processEvent} method.
598
* <p>Note that if the event parameter is {@code null}
599
* the behavior is unspecified and may result in an
600
* exception.
601
*
602
* @param e the event
603
* @see java.awt.event.ItemEvent
604
* @see #processItemEvent
605
* @since 1.1
606
*/
607
protected void processEvent(AWTEvent e) {
608
if (e instanceof ItemEvent) {
609
processItemEvent((ItemEvent)e);
610
return;
611
}
612
super.processEvent(e);
613
}
614
615
/**
616
* Processes item events occurring on this {@code Choice}
617
* menu by dispatching them to any registered
618
* {@code ItemListener} objects.
619
* <p>
620
* This method is not called unless item events are
621
* enabled for this component. Item events are enabled
622
* when one of the following occurs:
623
* <ul>
624
* <li>An {@code ItemListener} object is registered
625
* via {@code addItemListener}.
626
* <li>Item events are enabled via {@code enableEvents}.
627
* </ul>
628
* <p>Note that if the event parameter is {@code null}
629
* the behavior is unspecified and may result in an
630
* exception.
631
*
632
* @param e the item event
633
* @see java.awt.event.ItemEvent
634
* @see java.awt.event.ItemListener
635
* @see #addItemListener(ItemListener)
636
* @see java.awt.Component#enableEvents
637
* @since 1.1
638
*/
639
protected void processItemEvent(ItemEvent e) {
640
ItemListener listener = itemListener;
641
if (listener != null) {
642
listener.itemStateChanged(e);
643
}
644
}
645
646
/**
647
* Returns a string representing the state of this {@code Choice}
648
* menu. This method is intended to be used only for debugging purposes,
649
* and the content and format of the returned string may vary between
650
* implementations. The returned string may be empty but may not be
651
* {@code null}.
652
*
653
* @return the parameter string of this {@code Choice} menu
654
*/
655
protected String paramString() {
656
return super.paramString() + ",current=" + getSelectedItem();
657
}
658
659
660
/* Serialization support.
661
*/
662
663
/**
664
* Serialized data version.
665
* @serial
666
*/
667
private int choiceSerializedDataVersion = 1;
668
669
/**
670
* Writes default serializable fields to stream. Writes
671
* a list of serializable {@code ItemListeners}
672
* as optional data. The non-serializable
673
* {@code ItemListeners} are detected and
674
* no attempt is made to serialize them.
675
*
676
* @param s the {@code ObjectOutputStream} to write
677
* @throws IOException if an I/O error occurs
678
* @serialData {@code null} terminated sequence of 0
679
* or more pairs; the pair consists of a {@code String}
680
* and an {@code Object}; the {@code String} indicates
681
* the type of object and is one of the following:
682
* {@code itemListenerK} indicating an
683
* {@code ItemListener} object
684
*
685
* @see AWTEventMulticaster#save(ObjectOutputStream, String, EventListener)
686
* @see java.awt.Component#itemListenerK
687
* @see #readObject(ObjectInputStream)
688
*/
689
@Serial
690
private void writeObject(ObjectOutputStream s)
691
throws java.io.IOException
692
{
693
s.defaultWriteObject();
694
695
AWTEventMulticaster.save(s, itemListenerK, itemListener);
696
s.writeObject(null);
697
}
698
699
/**
700
* Reads the {@code ObjectInputStream} and if it
701
* isn't {@code null} adds a listener to receive
702
* item events fired by the {@code Choice} item.
703
* Unrecognized keys or values will be ignored.
704
*
705
* @param s the {@code ObjectInputStream} to read
706
* @throws ClassNotFoundException if the class of a serialized object could
707
* not be found
708
* @throws IOException if an I/O error occurs
709
* @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
710
* returns {@code true}
711
* @serial
712
* @see #removeItemListener(ItemListener)
713
* @see #addItemListener(ItemListener)
714
* @see java.awt.GraphicsEnvironment#isHeadless
715
* @see #writeObject(ObjectOutputStream)
716
*/
717
@Serial
718
private void readObject(ObjectInputStream s)
719
throws ClassNotFoundException, IOException, HeadlessException
720
{
721
GraphicsEnvironment.checkHeadless();
722
s.defaultReadObject();
723
724
Object keyOrNull;
725
while(null != (keyOrNull = s.readObject())) {
726
String key = ((String)keyOrNull).intern();
727
728
if (itemListenerK == key)
729
addItemListener((ItemListener)(s.readObject()));
730
731
else // skip value for unrecognized key
732
s.readObject();
733
}
734
}
735
736
/**
737
* Initialize JNI field and method IDs
738
*/
739
private static native void initIDs();
740
741
/////////////////
742
// Accessibility support
743
////////////////
744
745
746
/**
747
* Gets the {@code AccessibleContext} associated with this
748
* {@code Choice}. For {@code Choice} components,
749
* the {@code AccessibleContext} takes the form of an
750
* {@code AccessibleAWTChoice}. A new {@code AccessibleAWTChoice}
751
* instance is created if necessary.
752
*
753
* @return an {@code AccessibleAWTChoice} that serves as the
754
* {@code AccessibleContext} of this {@code Choice}
755
* @since 1.3
756
*/
757
public AccessibleContext getAccessibleContext() {
758
if (accessibleContext == null) {
759
accessibleContext = new AccessibleAWTChoice();
760
}
761
return accessibleContext;
762
}
763
764
/**
765
* This class implements accessibility support for the
766
* {@code Choice} class. It provides an implementation of the
767
* Java Accessibility API appropriate to choice user-interface elements.
768
* @since 1.3
769
*/
770
protected class AccessibleAWTChoice extends AccessibleAWTComponent
771
implements AccessibleAction
772
{
773
/**
774
* Use serialVersionUID from JDK 1.3 for interoperability.
775
*/
776
@Serial
777
private static final long serialVersionUID = 7175603582428509322L;
778
779
/**
780
* Constructor for {@code AccessibleAWTChoice}
781
*/
782
public AccessibleAWTChoice() {
783
super();
784
}
785
786
/**
787
* Get the AccessibleAction associated with this object. In the
788
* implementation of the Java Accessibility API for this class,
789
* return this object, which is responsible for implementing the
790
* AccessibleAction interface on behalf of itself.
791
*
792
* @return this object
793
* @see AccessibleAction
794
*/
795
public AccessibleAction getAccessibleAction() {
796
return this;
797
}
798
799
/**
800
* Get the role of this object.
801
*
802
* @return an instance of AccessibleRole describing the role of the
803
* object
804
* @see AccessibleRole
805
*/
806
public AccessibleRole getAccessibleRole() {
807
return AccessibleRole.COMBO_BOX;
808
}
809
810
/**
811
* Returns the number of accessible actions available in this object
812
* If there are more than one, the first one is considered the "default"
813
* action of the object.
814
*
815
* @return the zero-based number of Actions in this object
816
*/
817
public int getAccessibleActionCount() {
818
return 0; // To be fully implemented in a future release
819
}
820
821
/**
822
* Returns a description of the specified action of the object.
823
*
824
* @param i zero-based index of the actions
825
* @return a String description of the action
826
* @see #getAccessibleActionCount
827
*/
828
public String getAccessibleActionDescription(int i) {
829
return null; // To be fully implemented in a future release
830
}
831
832
/**
833
* Perform the specified Action on the object
834
*
835
* @param i zero-based index of actions
836
* @return true if the action was performed; otherwise false.
837
* @see #getAccessibleActionCount
838
*/
839
public boolean doAccessibleAction(int i) {
840
return false; // To be fully implemented in a future release
841
}
842
843
} // inner class AccessibleAWTChoice
844
845
}
846
847