1. /*
  2. * @(#)MenuComponent.java 1.56 00/04/06
  3. *
  4. * Copyright 1995-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package java.awt;
  11. import java.awt.peer.MenuComponentPeer;
  12. import java.awt.event.ActionEvent;
  13. import java.io.IOException;
  14. import java.io.ObjectInputStream;
  15. import sun.awt.AppContext;
  16. import sun.awt.SunToolkit;
  17. import javax.accessibility.*;
  18. /**
  19. * The abstract class <code>MenuComponent</code> is the superclass
  20. * of all menu-related components. In this respect, the class
  21. * <code>MenuComponent</code> is analogous to the abstract superclass
  22. * <code>Component</code> for AWT components.
  23. * <p>
  24. * Menu components receive and process AWT events, just as components do,
  25. * through the method <code>processEvent</code>.
  26. *
  27. * @version 1.56, 04/06/00
  28. * @author Arthur van Hoff
  29. * @since JDK1.0
  30. */
  31. public abstract class MenuComponent implements java.io.Serializable {
  32. static {
  33. /* ensure that the necessary native libraries are loaded */
  34. Toolkit.loadLibraries();
  35. initIDs();
  36. }
  37. transient MenuComponentPeer peer;
  38. transient MenuContainer parent;
  39. /**
  40. * The AppContext of the MenuComponent. This is set in the constructor
  41. * and never changes.
  42. */
  43. transient AppContext appContext;
  44. /**
  45. * The Menu Components Font.
  46. * This value can be null at which point a default will be used.
  47. *
  48. * @serial
  49. * @see setFont()
  50. * @see getFont()
  51. */
  52. Font font;
  53. /**
  54. * The Menu Components name.
  55. * @serial
  56. * @see getName()
  57. * @see setName()
  58. */
  59. private String name;
  60. /**
  61. * A variable to indicate whether a name is explicitly set.
  62. * If it is true the name will be set explicitly.
  63. * @serial
  64. * @see setName()
  65. */
  66. private boolean nameExplicitlySet = false;
  67. /**
  68. * @serial
  69. * @see dispatchEvent()
  70. */
  71. boolean newEventsOnly = false;
  72. /*
  73. * Internal constants for serialization
  74. */
  75. final static String actionListenerK = Component.actionListenerK;
  76. final static String itemListenerK = Component.itemListenerK;
  77. /*
  78. * JDK 1.1 serialVersionUID
  79. */
  80. private static final long serialVersionUID = -4536902356223894379L;
  81. /**
  82. * This object is used as a key for internal hashtables.
  83. */
  84. transient private Object privateKey = new Object();
  85. /**
  86. * Constructor for MenuComponent.
  87. */
  88. public MenuComponent() {
  89. appContext = AppContext.getAppContext();
  90. SunToolkit.insertTargetMapping(this, appContext);
  91. }
  92. /**
  93. * Construct a name for this MenuComponent. Called by getName() when
  94. * the name is null.
  95. */
  96. String constructComponentName() {
  97. return null; // For strict compliance with prior platform versions, a MenuComponent
  98. // that doesn't set its name should return null from
  99. // getName()
  100. }
  101. /**
  102. * Gets the name of the menu component.
  103. * @return the name of the menu component.
  104. * @see java.awt.MenuComponent#setName(java.lang.String)
  105. * @since JDK1.1
  106. */
  107. public String getName() {
  108. if (name == null && !nameExplicitlySet) {
  109. synchronized(this) {
  110. if (name == null && !nameExplicitlySet)
  111. name = constructComponentName();
  112. }
  113. }
  114. return name;
  115. }
  116. /**
  117. * Sets the name of the component to the specified string.
  118. * @param name the name of the menu component.
  119. * @see java.awt.MenuComponent#getName
  120. * @since JDK1.1
  121. */
  122. public void setName(String name) {
  123. synchronized(this) {
  124. this.name = name;
  125. nameExplicitlySet = true;
  126. }
  127. }
  128. /**
  129. * Returns the parent container for this menu component.
  130. * @return the menu component containing this menu component,
  131. * or <code>null</code> if this menu component
  132. * is the outermost component, the menu bar itself.
  133. */
  134. public MenuContainer getParent() {
  135. return getParent_NoClientCode();
  136. }
  137. // NOTE: This method may be called by privileged threads.
  138. // This functionality is implemented in a package-private method
  139. // to insure that it cannot be overridden by client subclasses.
  140. // DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  141. final MenuContainer getParent_NoClientCode() {
  142. return parent;
  143. }
  144. /**
  145. * @deprecated As of JDK version 1.1,
  146. * programs should not directly manipulate peers.
  147. */
  148. public MenuComponentPeer getPeer() {
  149. return peer;
  150. }
  151. /**
  152. * Gets the font used for this menu component.
  153. * @return the font used in this menu component, if there is one;
  154. * <code>null</code> otherwise.
  155. * @see java.awt.MenuComponent#setFont
  156. */
  157. public Font getFont() {
  158. Font font = this.font;
  159. if (font != null) {
  160. return font;
  161. }
  162. MenuContainer parent = this.parent;
  163. if (parent != null) {
  164. return parent.getFont();
  165. }
  166. return null;
  167. }
  168. // NOTE: This method may be called by privileged threads.
  169. // This functionality is implemented in a package-private method
  170. // to insure that it cannot be overridden by client subclasses.
  171. // DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  172. final Font getFont_NoClientCode() {
  173. Font font = this.font;
  174. if (font != null) {
  175. return font;
  176. }
  177. // The MenuContainer interface does not have getFont_NoClientCode()
  178. // and it cannot, because it must be package-private. Because of
  179. // this, we must manually cast classes that implement
  180. // MenuContainer.
  181. Object parent = this.parent;
  182. if (parent != null) {
  183. if (parent instanceof Component) {
  184. font = ((Component)parent).getFont_NoClientCode();
  185. } else if (parent instanceof MenuComponent) {
  186. font = ((MenuComponent)parent).getFont_NoClientCode();
  187. }
  188. }
  189. return font;
  190. } // getFont_NoClientCode()
  191. /**
  192. * Sets the font to be used for this menu component to the specified
  193. * font. This font is also used by all subcomponents of this menu
  194. * component, unless those subcomponents specify a different font.
  195. * @param f the font to be set.
  196. * @see java.awt.MenuComponent#getFont
  197. */
  198. public void setFont(Font f) {
  199. font = f;
  200. }
  201. /**
  202. * Removes the menu component's peer. The peer allows us to modify the
  203. * appearance of the menu component without changing the functionality of
  204. * the menu component.
  205. */
  206. public void removeNotify() {
  207. synchronized (getTreeLock()) {
  208. MenuComponentPeer p = (MenuComponentPeer)this.peer;
  209. if (p != null) {
  210. Toolkit.getEventQueue().removeSourceEvents(this);
  211. this.peer = null;
  212. p.dispose();
  213. }
  214. }
  215. }
  216. /**
  217. * Posts the specified event to the menu.
  218. * This method is part of the Java 1.0 event system
  219. * and it is maintained only for backwards compatibility.
  220. * Its use is discouraged, and it may not be supported
  221. * in the future.
  222. * @param evt the event which is to take place
  223. * @deprecated As of JDK version 1.1,
  224. * replaced by <code>dispatchEvent(AWTEvent)</code>.
  225. */
  226. public boolean postEvent(Event evt) {
  227. MenuContainer parent = this.parent;
  228. if (parent != null) {
  229. parent.postEvent(evt);
  230. }
  231. return false;
  232. }
  233. /*
  234. * Delivers an event to this component or one of its sub components.
  235. * @param e the event
  236. */
  237. public final void dispatchEvent(AWTEvent e) {
  238. dispatchEventImpl(e);
  239. }
  240. void dispatchEventImpl(AWTEvent e) {
  241. Toolkit.getDefaultToolkit().notifyAWTEventListeners(e);
  242. if (newEventsOnly ||
  243. (parent != null && parent instanceof MenuComponent &&
  244. ((MenuComponent)parent).newEventsOnly)) {
  245. if (eventEnabled(e)) {
  246. processEvent(e);
  247. } else if (e instanceof ActionEvent && parent != null) {
  248. ((MenuComponent)parent).dispatchEvent(new ActionEvent(parent,
  249. e.getID(),
  250. ((ActionEvent)e).getActionCommand()));
  251. }
  252. } else { // backward compatibility
  253. Event olde = e.convertToOld();
  254. if (olde != null) {
  255. postEvent(olde);
  256. }
  257. }
  258. }
  259. // REMIND: remove when filtering is done at lower level
  260. boolean eventEnabled(AWTEvent e) {
  261. return false;
  262. }
  263. /**
  264. * Processes events occurring on this menu component.
  265. *
  266. * @param e the event
  267. * @since JDK1.1
  268. */
  269. protected void processEvent(AWTEvent e) {
  270. }
  271. /**
  272. * Returns the parameter string representing the state of this
  273. * menu component. This string is useful for debugging.
  274. * @return the parameter string of this menu component.
  275. */
  276. protected String paramString() {
  277. String thisName = getName();
  278. return (thisName != null? thisName : "");
  279. }
  280. /**
  281. * Returns a representation of this menu component as a string.
  282. * @return a string representation of this menu component.
  283. */
  284. public String toString() {
  285. return getClass().getName() + "[" + paramString() + "]";
  286. }
  287. /**
  288. * Gets this component's locking object (the object that owns the thread
  289. * sychronization monitor) for AWT component-tree and layout
  290. * operations.
  291. * @return This component's locking object.
  292. */
  293. protected final Object getTreeLock() {
  294. return Component.LOCK;
  295. }
  296. private void readObject(ObjectInputStream s)
  297. throws ClassNotFoundException, IOException
  298. {
  299. s.defaultReadObject();
  300. privateKey = new Object();
  301. appContext = AppContext.getAppContext();
  302. SunToolkit.insertTargetMapping(this, appContext);
  303. }
  304. /**
  305. * Initialize JNI field and method IDs
  306. */
  307. private static native void initIDs();
  308. /*
  309. * --- Accessibility Support ---
  310. *
  311. * MenuComponent will contain all of the methods in interface Accessible,
  312. * though it won't actually implement the interface - that will be up
  313. * to the individual objects which extend MenuComponent.
  314. */
  315. AccessibleContext accessibleContext = null;
  316. /**
  317. * Get the AccessibleContext associated with this MenuComponent
  318. *
  319. * @return the AccessibleContext of this MenuComponent
  320. */
  321. public AccessibleContext getAccessibleContext() {
  322. return accessibleContext;
  323. }
  324. /**
  325. * Inner class of MenuComponent used to provide default support for
  326. * accessibility. This class is not meant to be used directly by
  327. * application developers, but is instead meant only to be
  328. * subclassed by menu component developers.
  329. * <p>
  330. * The class used to obtain the accessible role for this object.
  331. */
  332. protected abstract class AccessibleAWTMenuComponent
  333. extends AccessibleContext
  334. implements java.io.Serializable, AccessibleComponent,
  335. AccessibleSelection {
  336. /**
  337. * Although the class is abstract, this should be called by
  338. * all sub-classes.
  339. */
  340. protected AccessibleAWTMenuComponent() {
  341. }
  342. // AccessibleContext methods
  343. //
  344. /**
  345. * Get the AccessibleSelection associated with this object which allows
  346. * its Accessible children to be selected.
  347. *
  348. * @return AccessibleSelection if supported by object; else return null
  349. * @see AccessibleSelection
  350. */
  351. public AccessibleSelection getAccessibleSelection() {
  352. return this;
  353. }
  354. /**
  355. * Get the accessible name of this object. This should almost never
  356. * return java.awt.MenuComponent.getName(), as that generally isn't
  357. * a localized name, and doesn't have meaning for the user. If the
  358. * object is fundamentally a text object (e.g. a menu item), the
  359. * accessible name should be the text of the object (e.g. "save").
  360. * If the object has a tooltip, the tooltip text may also be an
  361. * appropriate String to return.
  362. *
  363. * @return the localized name of the object -- can be null if this
  364. * object does not have a name
  365. * @see AccessibleContext#setAccessibleName
  366. */
  367. public String getAccessibleName() {
  368. return accessibleName;
  369. }
  370. /**
  371. * Get the accessible description of this object. This should be
  372. * a concise, localized description of what this object is - what
  373. * is its meaning to the user. If the object has a tooltip, the
  374. * tooltip text may be an appropriate string to return, assuming
  375. * it contains a concise description of the object (instead of just
  376. * the name of the object - e.g. a "Save" icon on a toolbar that
  377. * had "save" as the tooltip text shouldn't return the tooltip
  378. * text as the description, but something like "Saves the current
  379. * text document" instead).
  380. *
  381. * @return the localized description of the object -- can be null if
  382. * this object does not have a description
  383. * @see AccessibleContext#setAccessibleDescription
  384. */
  385. public String getAccessibleDescription() {
  386. return accessibleDescription;
  387. }
  388. /**
  389. * Get the role of this object.
  390. *
  391. * @return an instance of AccessibleRole describing the role of the
  392. * object
  393. * @see AccessibleRole
  394. */
  395. public AccessibleRole getAccessibleRole() {
  396. return AccessibleRole.AWT_COMPONENT; // Non-specific -- overridden in subclasses
  397. }
  398. /**
  399. * Get the state of this object.
  400. *
  401. * @return an instance of AccessibleStateSet containing the current
  402. * state set of the object
  403. * @see AccessibleState
  404. */
  405. public AccessibleStateSet getAccessibleStateSet() {
  406. return MenuComponent.this.getAccessibleStateSet();
  407. }
  408. /**
  409. * Get the Accessible parent of this object. If the parent of this
  410. * object implements Accessible, this method should simply return
  411. * getParent().
  412. *
  413. * @return the Accessible parent of this object -- can be null if this
  414. * object does not have an Accessible parent
  415. */
  416. public Accessible getAccessibleParent() {
  417. if (accessibleParent != null) {
  418. return accessibleParent;
  419. } else {
  420. MenuContainer parent = MenuComponent.this.getParent();
  421. if (parent instanceof Accessible) {
  422. return (Accessible) parent;
  423. }
  424. }
  425. return null;
  426. }
  427. /**
  428. * Get the index of this object in its accessible parent.
  429. *
  430. * @return the index of this object in its parent; -1 if this
  431. * object does not have an accessible parent.
  432. * @see #getAccessibleParent
  433. */
  434. public int getAccessibleIndexInParent() {
  435. return MenuComponent.this.getAccessibleIndexInParent();
  436. }
  437. /**
  438. * Returns the number of accessible children in the object. If all
  439. * of the children of this object implement Accessible, than this
  440. * method should return the number of children of this object.
  441. *
  442. * @return the number of accessible children in the object.
  443. */
  444. public int getAccessibleChildrenCount() {
  445. return 0; // MenuComponents don't have children
  446. }
  447. /**
  448. * Return the nth Accessible child of the object.
  449. *
  450. * @param i zero-based index of child
  451. * @return the nth Accessible child of the object
  452. */
  453. public Accessible getAccessibleChild(int i) {
  454. return null; // MenuComponents don't have children
  455. }
  456. /**
  457. * Return the locale of this object.
  458. *
  459. * @return the locale of this object
  460. */
  461. public java.util.Locale getLocale() {
  462. MenuContainer parent = MenuComponent.this.getParent();
  463. if (parent instanceof Component)
  464. return ((Component)parent).getLocale();
  465. else
  466. return java.util.Locale.getDefault();
  467. }
  468. /**
  469. * Get the AccessibleComponent associated with this object if one
  470. * exists. Otherwise return null.
  471. *
  472. * @return the component
  473. */
  474. public AccessibleComponent getAccessibleComponent() {
  475. return this;
  476. }
  477. // AccessibleComponent methods
  478. //
  479. /**
  480. * Get the background color of this object.
  481. *
  482. * @return the background color, if supported, of the object;
  483. * otherwise, null
  484. */
  485. public Color getBackground() {
  486. return null; // Not supported for MenuComponents
  487. }
  488. /**
  489. * Set the background color of this object.
  490. * (For transparency, see <code>isOpaque</code>.)
  491. *
  492. * @param c the new Color for the background
  493. * @see Component#isOpaque
  494. */
  495. public void setBackground(Color c) {
  496. // Not supported for MenuComponents
  497. }
  498. /**
  499. * Get the foreground color of this object.
  500. *
  501. * @return the foreground color, if supported, of the object;
  502. * otherwise, null
  503. */
  504. public Color getForeground() {
  505. return null; // Not supported for MenuComponents
  506. }
  507. /**
  508. * Set the foreground color of this object.
  509. *
  510. * @param c the new Color for the foreground
  511. */
  512. public void setForeground(Color c) {
  513. // Not supported for MenuComponents
  514. }
  515. /**
  516. * Get the Cursor of this object.
  517. *
  518. * @return the Cursor, if supported, of the object; otherwise, null
  519. */
  520. public Cursor getCursor() {
  521. return null; // Not supported for MenuComponents
  522. }
  523. /**
  524. * Set the Cursor of this object.
  525. *
  526. * @param c the new Cursor for the object
  527. */
  528. public void setCursor(Cursor cursor) {
  529. // Not supported for MenuComponents
  530. }
  531. /**
  532. * Get the Font of this object.
  533. *
  534. * @return the Font,if supported, for the object; otherwise, null
  535. */
  536. public Font getFont() {
  537. return MenuComponent.this.getFont();
  538. }
  539. /**
  540. * Set the Font of this object.
  541. *
  542. * @param f the new Font for the object
  543. */
  544. public void setFont(Font f) {
  545. MenuComponent.this.setFont(f);
  546. }
  547. /**
  548. * Get the FontMetrics of this object.
  549. *
  550. * @param f the Font
  551. * @return the FontMetrics, if supported, the object; otherwise, null
  552. * @see #getFont
  553. */
  554. public FontMetrics getFontMetrics(Font f) {
  555. return null; // Not supported for MenuComponents
  556. }
  557. /**
  558. * Determine if the object is enabled.
  559. *
  560. * @return true if object is enabled; otherwise, false
  561. */
  562. public boolean isEnabled() {
  563. return true; // Not supported for MenuComponents
  564. }
  565. /**
  566. * Set the enabled state of the object.
  567. *
  568. * @param b if true, enables this object; otherwise, disables it
  569. */
  570. public void setEnabled(boolean b) {
  571. // Not supported for MenuComponents
  572. }
  573. /**
  574. * Determine if the object is visible. Note: this means that the
  575. * object intends to be visible; however, it may not in fact be
  576. * showing on the screen because one of the objects that this object
  577. * is contained by is not visible. To determine if an object is
  578. * showing on the screen, use isShowing().
  579. *
  580. * @return true if object is visible; otherwise, false
  581. */
  582. public boolean isVisible() {
  583. return true; // Not supported for MenuComponents
  584. }
  585. /**
  586. * Set the visible state of the object.
  587. *
  588. * @param b if true, shows this object; otherwise, hides it
  589. */
  590. public void setVisible(boolean b) {
  591. // Not supported for MenuComponents
  592. }
  593. /**
  594. * Determine if the object is showing. This is determined by checking
  595. * the visibility of the object and ancestors of the object. Note:
  596. * this will return true even if the object is obscured by another
  597. * (for example, it happens to be underneath a menu that was pulled
  598. * down).
  599. *
  600. * @return true if object is showing; otherwise, false
  601. */
  602. public boolean isShowing() {
  603. return true; // Not supported for MenuComponents
  604. }
  605. /**
  606. * Checks whether the specified point is within this object's bounds,
  607. * where the point's x and y coordinates are defined to be relative to
  608. * the coordinate system of the object.
  609. *
  610. * @param p the Point relative to the coordinate system of the object
  611. * @return true if object contains Point; otherwise false
  612. */
  613. public boolean contains(Point p) {
  614. return false; // Not supported for MenuComponents
  615. }
  616. /**
  617. * Returns the location of the object on the screen.
  618. *
  619. * @return location of object on screen -- can be null if this object
  620. * is not on the screen
  621. */
  622. public Point getLocationOnScreen() {
  623. return null; // Not supported for MenuComponents
  624. }
  625. /**
  626. * Gets the location of the object relative to the parent in the form
  627. * of a point specifying the object's top-left corner in the screen's
  628. * coordinate space.
  629. *
  630. * @return An instance of Point representing the top-left corner of
  631. * the object's bounds in the coordinate space of the screen; null if
  632. * this object or its parent are not on the screen
  633. */
  634. public Point getLocation() {
  635. return null; // Not supported for MenuComponents
  636. }
  637. /**
  638. * Sets the location of the object relative to the parent.
  639. */
  640. public void setLocation(Point p) {
  641. // Not supported for MenuComponents
  642. }
  643. /**
  644. * Gets the bounds of this object in the form of a Rectangle object.
  645. * The bounds specify this object's width, height, and location
  646. * relative to its parent.
  647. *
  648. * @return A rectangle indicating this component's bounds; null if
  649. * this object is not on the screen.
  650. */
  651. public Rectangle getBounds() {
  652. return null; // Not supported for MenuComponents
  653. }
  654. /**
  655. * Sets the bounds of this object in the form of a Rectangle object.
  656. * The bounds specify this object's width, height, and location
  657. * relative to its parent.
  658. *
  659. * @param A rectangle indicating this component's bounds
  660. */
  661. public void setBounds(Rectangle r) {
  662. // Not supported for MenuComponents
  663. }
  664. /**
  665. * Returns the size of this object in the form of a Dimension object.
  666. * The height field of the Dimension object contains this object's
  667. * height, and the width field of the Dimension object contains this
  668. * object's width.
  669. *
  670. * @return A Dimension object that indicates the size of this
  671. * component; null if this object is not on the screen
  672. */
  673. public Dimension getSize() {
  674. return null; // Not supported for MenuComponents
  675. }
  676. /**
  677. * Resizes this object..
  678. *
  679. * @param d - The dimension specifying the new size of the object.
  680. */
  681. public void setSize(Dimension d) {
  682. // Not supported for MenuComponents
  683. }
  684. /**
  685. * Returns the Accessible child, if one exists, contained at the local
  686. * coordinate Point.
  687. *
  688. * @param p The point defining the top-left corner of the Accessible,
  689. * given in the coordinate space of the object's parent.
  690. * @return the Accessible, if it exists, at the specified location;
  691. * else null
  692. */
  693. public Accessible getAccessibleAt(Point p) {
  694. return null; // MenuComponents don't have children
  695. }
  696. /**
  697. * Returns whether this object can accept focus or not.
  698. *
  699. * @return true if object can accept focus; otherwise false
  700. */
  701. public boolean isFocusTraversable() {
  702. return true; // Not supported for MenuComponents
  703. }
  704. /**
  705. * Requests focus for this object.
  706. */
  707. public void requestFocus() {
  708. // Not supported for MenuComponents
  709. }
  710. /**
  711. * Adds the specified focus listener to receive focus events from this
  712. * component.
  713. *
  714. * @param l the focus listener
  715. */
  716. public void addFocusListener(java.awt.event.FocusListener l) {
  717. // Not supported for MenuComponents
  718. }
  719. /**
  720. * Removes the specified focus listener so it no longer receives focus
  721. * events from this component.
  722. *
  723. * @param l the focus listener
  724. */
  725. public void removeFocusListener(java.awt.event.FocusListener l) {
  726. // Not supported for MenuComponents
  727. }
  728. // AccessibleSelection methods
  729. //
  730. /**
  731. * Returns the number of Accessible children currently selected.
  732. * If no children are selected, the return value will be 0.
  733. *
  734. * @return the number of items currently selected.
  735. */
  736. public int getAccessibleSelectionCount() {
  737. return 0; // To be fully implemented in a future release
  738. }
  739. /**
  740. * Returns an Accessible representing the specified selected child
  741. * in the object. If there isn't a selection, or there are
  742. * fewer children selected than the integer passed in, the return
  743. * value will be null.
  744. * <p>Note that the index represents the i-th selected child, which
  745. * is different from the i-th child.
  746. *
  747. * @param i the zero-based index of selected children
  748. * @return the i-th selected child
  749. * @see #getAccessibleSelectionCount
  750. */
  751. public Accessible getAccessibleSelection(int i) {
  752. return null; // To be fully implemented in a future release
  753. }
  754. /**
  755. * Determines if the current child of this object is selected.
  756. *
  757. * @return true if the current child of this object is selected;
  758. * else false.
  759. * @param i the zero-based index of the child in this Accessible object.
  760. * @see AccessibleContext#getAccessibleChild
  761. */
  762. public boolean isAccessibleChildSelected(int i) {
  763. return false; // To be fully implemented in a future release
  764. }
  765. /**
  766. * Adds the specified Accessible child of the object to the object's
  767. * selection. If the object supports multiple selections,
  768. * the specified child is added to any existing selection, otherwise
  769. * it replaces any existing selection in the object. If the
  770. * specified child is already selected, this method has no effect.
  771. *
  772. * @param i the zero-based index of the child
  773. * @see AccessibleContext#getAccessibleChild
  774. */
  775. public void addAccessibleSelection(int i) {
  776. // To be fully implemented in a future release
  777. }
  778. /**
  779. * Removes the specified child of the object from the object's
  780. * selection. If the specified item isn't currently selected, this
  781. * method has no effect.
  782. *
  783. * @param i the zero-based index of the child
  784. * @see AccessibleContext#getAccessibleChild
  785. */
  786. public void removeAccessibleSelection(int i) {
  787. // To be fully implemented in a future release
  788. }
  789. /**
  790. * Clears the selection in the object, so that no children in the
  791. * object are selected.
  792. */
  793. public void clearAccessibleSelection() {
  794. // To be fully implemented in a future release
  795. }
  796. /**
  797. * Causes every child of the object to be selected
  798. * if the object supports multiple selections.
  799. */
  800. public void selectAllAccessibleSelection() {
  801. // To be fully implemented in a future release
  802. }
  803. } // inner class AccessibleAWTComponent
  804. /**
  805. * Get the index of this object in its accessible parent.
  806. *
  807. * @return -1 of this object does not have an accessible parent.
  808. * Otherwise, the index of the child in its accessible parent.
  809. */
  810. int getAccessibleIndexInParent() {
  811. return -1; // Overridden in subclasses
  812. }
  813. /**
  814. * Get the state of this object.
  815. *
  816. * @return an instance of AccessibleStateSet containing the current state
  817. * set of the object
  818. * @see AccessibleState
  819. */
  820. AccessibleStateSet getAccessibleStateSet() {
  821. AccessibleStateSet states = new AccessibleStateSet();
  822. return states;
  823. }
  824. }