1. /*
  2. * @(#)AccessibleComponent.java 1.12 00/02/02
  3. *
  4. * Copyright 1997-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 javax.accessibility;
  11. import java.awt.*;
  12. import java.awt.event.*;
  13. /**
  14. * The AccessibleComponent interface should be supported by any object
  15. * that is rendered on the screen. This interface provides the standard
  16. * mechanism for an assistive technology to determine and set the
  17. * graphical representation of an object. Applications can determine
  18. * if an object supports the AccessibleComponent interface by first
  19. * obtaining its AccessibleContext
  20. * and then calling the
  21. * {@link AccessibleContext#getAccessibleComponent} method.
  22. * If the return value is not null, the object supports this interface.
  23. *
  24. * @see Accessible
  25. * @see Accessible#getAccessibleContext
  26. * @see AccessibleContext
  27. * @see AccessibleContext#getAccessibleComponent
  28. *
  29. * @version 1.7 10/05/99 14:00:28
  30. * @author Peter Korn
  31. * @author Hans Muller
  32. * @author Willie Walker
  33. */
  34. public interface AccessibleComponent {
  35. /**
  36. * Gets the background color of this object.
  37. *
  38. * @return the background color, if supported, of the object;
  39. * otherwise, null
  40. * @see #setBackground
  41. */
  42. public Color getBackground();
  43. /**
  44. * Sets the background color of this object.
  45. *
  46. * @param c the new Color for the background
  47. * @see #setBackground
  48. */
  49. public void setBackground(Color c);
  50. /**
  51. * Gets the foreground color of this object.
  52. *
  53. * @return the foreground color, if supported, of the object;
  54. * otherwise, null
  55. * @see #setForeground
  56. */
  57. public Color getForeground();
  58. /**
  59. * Sets the foreground color of this object.
  60. *
  61. * @param c the new Color for the foreground
  62. * @see #getForeground
  63. */
  64. public void setForeground(Color c);
  65. /**
  66. * Gets the Cursor of this object.
  67. *
  68. * @return the Cursor, if supported, of the object; otherwise, null
  69. * @see #setCursor
  70. */
  71. public Cursor getCursor();
  72. /**
  73. * Sets the Cursor of this object.
  74. *
  75. * @param c the new Cursor for the object
  76. * @see #getCursor
  77. */
  78. public void setCursor(Cursor cursor);
  79. /**
  80. * Gets the Font of this object.
  81. *
  82. * @return the Font,if supported, for the object; otherwise, null
  83. * @see #setFont
  84. */
  85. public Font getFont();
  86. /**
  87. * Sets the Font of this object.
  88. *
  89. * @param f the new Font for the object
  90. * @see #getFont
  91. */
  92. public void setFont(Font f);
  93. /**
  94. * Gets the FontMetrics of this object.
  95. *
  96. * @param f the Font
  97. * @return the FontMetrics, if supported, the object; otherwise, null
  98. * @see #getFont
  99. */
  100. public FontMetrics getFontMetrics(Font f);
  101. /**
  102. * Determines if the object is enabled. Objects that are enabled
  103. * will also have the AccessibleState.ENABLED state set in their
  104. * AccessibleStateSets.
  105. *
  106. * @return true if object is enabled; otherwise, false
  107. * @see #setEnabled
  108. * @see AccessibleContext#getAccessibleStateSet
  109. * @see AccessibleState#ENABLED
  110. * @see AccessibleStateSet
  111. */
  112. public boolean isEnabled();
  113. /**
  114. * Sets the enabled state of the object.
  115. *
  116. * @param b if true, enables this object; otherwise, disables it
  117. * @see #isEnabled
  118. */
  119. public void setEnabled(boolean b);
  120. /**
  121. * Determines if the object is visible. Note: this means that the
  122. * object intends to be visible; however, it may not be
  123. * showing on the screen because one of the objects that this object
  124. * is contained by is currently not visible. To determine if an object is
  125. * showing on the screen, use isShowing().
  126. * <p>Objects that are visible will also have the
  127. * AccessibleState.VISIBLE state set in their AccessibleStateSets.
  128. *
  129. * @return true if object is visible; otherwise, false
  130. * @see #setVisible
  131. * @see AccessibleContext#getAccessibleStateSet
  132. * @see AccessibleState#VISIBLE
  133. * @see AccessibleStateSet
  134. */
  135. public boolean isVisible();
  136. /**
  137. * Sets the visible state of the object.
  138. *
  139. * @param b if true, shows this object; otherwise, hides it
  140. * @see #isVisible
  141. */
  142. public void setVisible(boolean b);
  143. /**
  144. * Determines if the object is showing. This is determined by checking
  145. * the visibility of the object and its ancestors.
  146. * Note: this
  147. * will return true even if the object is obscured by another (for example,
  148. * it is underneath a menu that was pulled down).
  149. *
  150. * @return true if object is showing; otherwise, false
  151. */
  152. public boolean isShowing();
  153. /**
  154. * Checks whether the specified point is within this object's bounds,
  155. * where the point's x and y coordinates are defined to be relative to the
  156. * coordinate system of the object.
  157. *
  158. * @param p the Point relative to the coordinate system of the object
  159. * @return true if object contains Point; otherwise false
  160. * @see #getBounds
  161. */
  162. public boolean contains(Point p);
  163. /**
  164. * Returns the location of the object on the screen.
  165. *
  166. * @return the location of the object on screen; null if this object
  167. * is not on the screen
  168. * @see #getBounds
  169. * @see #getLocation
  170. */
  171. public Point getLocationOnScreen();
  172. /**
  173. * Gets the location of the object relative to the parent in the form
  174. * of a point specifying the object's top-left corner in the screen's
  175. * coordinate space.
  176. *
  177. * @return An instance of Point representing the top-left corner of the
  178. * object's bounds in the coordinate space of the screen; null if
  179. * this object or its parent are not on the screen
  180. * @see #getBounds
  181. * @see #getLocationOnScreen
  182. */
  183. public Point getLocation();
  184. /**
  185. * Sets the location of the object relative to the parent.
  186. * @param p the new position for the top-left corner
  187. * @see #getLocation
  188. */
  189. public void setLocation(Point p);
  190. /**
  191. * Gets the bounds of this object in the form of a Rectangle object.
  192. * The bounds specify this object's width, height, and location
  193. * relative to its parent.
  194. *
  195. * @return A rectangle indicating this component's bounds; null if
  196. * this object is not on the screen.
  197. * @see #contains
  198. */
  199. public Rectangle getBounds();
  200. /**
  201. * Sets the bounds of this object in the form of a Rectangle object.
  202. * The bounds specify this object's width, height, and location
  203. * relative to its parent.
  204. *
  205. * @param r rectangle indicating this component's bounds
  206. * @see #getBounds
  207. */
  208. public void setBounds(Rectangle r);
  209. /**
  210. * Returns the size of this object in the form of a Dimension object.
  211. * The height field of the Dimension object contains this object's
  212. * height, and the width field of the Dimension object contains this
  213. * object's width.
  214. *
  215. * @return A Dimension object that indicates the size of this component;
  216. * null if this object is not on the screen
  217. * @see #setSize
  218. */
  219. public Dimension getSize();
  220. /**
  221. * Resizes this object so that it has width and height.
  222. *
  223. * @param d The dimension specifying the new size of the object.
  224. * @see #getSize
  225. */
  226. public void setSize(Dimension d);
  227. /**
  228. * Returns the Accessible child, if one exists, contained at the local
  229. * coordinate Point.
  230. *
  231. * @param p The point relative to the coordinate system of this object.
  232. * @return the Accessible, if it exists, at the specified location;
  233. * otherwise null
  234. */
  235. public Accessible getAccessibleAt(Point p);
  236. /**
  237. * Returns whether this object can accept focus or not. Objects that
  238. * can accept focus will also have the AccessibleState.FOCUSABLE state
  239. * set in their AccessibleStateSets.
  240. *
  241. * @return true if object can accept focus; otherwise false
  242. * @see AccessibleContext#getAccessibleStateSet
  243. * @see AccessibleState#FOCUSABLE
  244. * @see AccessibleState#FOCUSED
  245. * @see AccessibleStateSet
  246. */
  247. public boolean isFocusTraversable();
  248. /**
  249. * Requests focus for this object. If this object cannot accept focus,
  250. * nothing will happen. Otherwise, the object will attempt to take
  251. * focus.
  252. * @see #isFocusTraversable
  253. */
  254. public void requestFocus();
  255. /**
  256. * Adds the specified focus listener to receive focus events from this
  257. * component.
  258. *
  259. * @param l the focus listener
  260. * @see #removeFocusListener
  261. */
  262. public void addFocusListener(FocusListener l);
  263. /**
  264. * Removes the specified focus listener so it no longer receives focus
  265. * events from this component.
  266. *
  267. * @param l the focus listener
  268. * @see #addFocusListener
  269. */
  270. public void removeFocusListener(FocusListener l);
  271. }