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