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