001 /*
002 * Copyright 1997-2003 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package javax.accessibility;
027
028 import java.awt.*;
029 import java.awt.event.*;
030
031 /**
032 * The AccessibleComponent interface should be supported by any object
033 * that is rendered on the screen. This interface provides the standard
034 * mechanism for an assistive technology to determine and set the
035 * graphical representation of an object. Applications can determine
036 * if an object supports the AccessibleComponent interface by first
037 * obtaining its AccessibleContext
038 * and then calling the
039 * {@link AccessibleContext#getAccessibleComponent} method.
040 * If the return value is not null, the object supports this interface.
041 *
042 * @see Accessible
043 * @see Accessible#getAccessibleContext
044 * @see AccessibleContext
045 * @see AccessibleContext#getAccessibleComponent
046 *
047 * @version 1.7 10/05/99 14:00:28
048 * @author Peter Korn
049 * @author Hans Muller
050 * @author Willie Walker
051 */
052 public interface AccessibleComponent {
053
054 /**
055 * Gets the background color of this object.
056 *
057 * @return the background color, if supported, of the object;
058 * otherwise, null
059 * @see #setBackground
060 */
061 public Color getBackground();
062
063 /**
064 * Sets the background color of this object.
065 *
066 * @param c the new Color for the background
067 * @see #setBackground
068 */
069 public void setBackground(Color c);
070
071 /**
072 * Gets the foreground color of this object.
073 *
074 * @return the foreground color, if supported, of the object;
075 * otherwise, null
076 * @see #setForeground
077 */
078 public Color getForeground();
079
080 /**
081 * Sets the foreground color of this object.
082 *
083 * @param c the new Color for the foreground
084 * @see #getForeground
085 */
086 public void setForeground(Color c);
087
088 /**
089 * Gets the Cursor of this object.
090 *
091 * @return the Cursor, if supported, of the object; otherwise, null
092 * @see #setCursor
093 */
094 public Cursor getCursor();
095
096 /**
097 * Sets the Cursor of this object.
098 *
099 * @param cursor the new Cursor for the object
100 * @see #getCursor
101 */
102 public void setCursor(Cursor cursor);
103
104 /**
105 * Gets the Font of this object.
106 *
107 * @return the Font,if supported, for the object; otherwise, null
108 * @see #setFont
109 */
110 public Font getFont();
111
112 /**
113 * Sets the Font of this object.
114 *
115 * @param f the new Font for the object
116 * @see #getFont
117 */
118 public void setFont(Font f);
119
120 /**
121 * Gets the FontMetrics of this object.
122 *
123 * @param f the Font
124 * @return the FontMetrics, if supported, the object; otherwise, null
125 * @see #getFont
126 */
127 public FontMetrics getFontMetrics(Font f);
128
129 /**
130 * Determines if the object is enabled. Objects that are enabled
131 * will also have the AccessibleState.ENABLED state set in their
132 * AccessibleStateSets.
133 *
134 * @return true if object is enabled; otherwise, false
135 * @see #setEnabled
136 * @see AccessibleContext#getAccessibleStateSet
137 * @see AccessibleState#ENABLED
138 * @see AccessibleStateSet
139 */
140 public boolean isEnabled();
141
142 /**
143 * Sets the enabled state of the object.
144 *
145 * @param b if true, enables this object; otherwise, disables it
146 * @see #isEnabled
147 */
148 public void setEnabled(boolean b);
149
150 /**
151 * Determines if the object is visible. Note: this means that the
152 * object intends to be visible; however, it may not be
153 * showing on the screen because one of the objects that this object
154 * is contained by is currently not visible. To determine if an object is
155 * showing on the screen, use isShowing().
156 * <p>Objects that are visible will also have the
157 * AccessibleState.VISIBLE state set in their AccessibleStateSets.
158 *
159 * @return true if object is visible; otherwise, false
160 * @see #setVisible
161 * @see AccessibleContext#getAccessibleStateSet
162 * @see AccessibleState#VISIBLE
163 * @see AccessibleStateSet
164 */
165 public boolean isVisible();
166
167 /**
168 * Sets the visible state of the object.
169 *
170 * @param b if true, shows this object; otherwise, hides it
171 * @see #isVisible
172 */
173 public void setVisible(boolean b);
174
175 /**
176 * Determines if the object is showing. This is determined by checking
177 * the visibility of the object and its ancestors.
178 * Note: this
179 * will return true even if the object is obscured by another (for example,
180 * it is underneath a menu that was pulled down).
181 *
182 * @return true if object is showing; otherwise, false
183 */
184 public boolean isShowing();
185
186 /**
187 * Checks whether the specified point is within this object's bounds,
188 * where the point's x and y coordinates are defined to be relative to the
189 * coordinate system of the object.
190 *
191 * @param p the Point relative to the coordinate system of the object
192 * @return true if object contains Point; otherwise false
193 * @see #getBounds
194 */
195 public boolean contains(Point p);
196
197 /**
198 * Returns the location of the object on the screen.
199 *
200 * @return the location of the object on screen; null if this object
201 * is not on the screen
202 * @see #getBounds
203 * @see #getLocation
204 */
205 public Point getLocationOnScreen();
206
207 /**
208 * Gets the location of the object relative to the parent in the form
209 * of a point specifying the object's top-left corner in the screen's
210 * coordinate space.
211 *
212 * @return An instance of Point representing the top-left corner of the
213 * object's bounds in the coordinate space of the screen; null if
214 * this object or its parent are not on the screen
215 * @see #getBounds
216 * @see #getLocationOnScreen
217 */
218 public Point getLocation();
219
220 /**
221 * Sets the location of the object relative to the parent.
222 * @param p the new position for the top-left corner
223 * @see #getLocation
224 */
225 public void setLocation(Point p);
226
227 /**
228 * Gets the bounds of this object in the form of a Rectangle object.
229 * The bounds specify this object's width, height, and location
230 * relative to its parent.
231 *
232 * @return A rectangle indicating this component's bounds; null if
233 * this object is not on the screen.
234 * @see #contains
235 */
236 public Rectangle getBounds();
237
238 /**
239 * Sets the bounds of this object in the form of a Rectangle object.
240 * The bounds specify this object's width, height, and location
241 * relative to its parent.
242 *
243 * @param r rectangle indicating this component's bounds
244 * @see #getBounds
245 */
246 public void setBounds(Rectangle r);
247
248 /**
249 * Returns the size of this object in the form of a Dimension object.
250 * The height field of the Dimension object contains this object's
251 * height, and the width field of the Dimension object contains this
252 * object's width.
253 *
254 * @return A Dimension object that indicates the size of this component;
255 * null if this object is not on the screen
256 * @see #setSize
257 */
258 public Dimension getSize();
259
260 /**
261 * Resizes this object so that it has width and height.
262 *
263 * @param d The dimension specifying the new size of the object.
264 * @see #getSize
265 */
266 public void setSize(Dimension d);
267
268 /**
269 * Returns the Accessible child, if one exists, contained at the local
270 * coordinate Point.
271 *
272 * @param p The point relative to the coordinate system of this object.
273 * @return the Accessible, if it exists, at the specified location;
274 * otherwise null
275 */
276 public Accessible getAccessibleAt(Point p);
277
278 /**
279 * Returns whether this object can accept focus or not. Objects that
280 * can accept focus will also have the AccessibleState.FOCUSABLE state
281 * set in their AccessibleStateSets.
282 *
283 * @return true if object can accept focus; otherwise false
284 * @see AccessibleContext#getAccessibleStateSet
285 * @see AccessibleState#FOCUSABLE
286 * @see AccessibleState#FOCUSED
287 * @see AccessibleStateSet
288 */
289 public boolean isFocusTraversable();
290
291 /**
292 * Requests focus for this object. If this object cannot accept focus,
293 * nothing will happen. Otherwise, the object will attempt to take
294 * focus.
295 * @see #isFocusTraversable
296 */
297 public void requestFocus();
298
299 /**
300 * Adds the specified focus listener to receive focus events from this
301 * component.
302 *
303 * @param l the focus listener
304 * @see #removeFocusListener
305 */
306 public void addFocusListener(FocusListener l);
307
308 /**
309 * Removes the specified focus listener so it no longer receives focus
310 * events from this component.
311 *
312 * @param l the focus listener
313 * @see #addFocusListener
314 */
315 public void removeFocusListener(FocusListener l);
316 }
|