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