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