KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > accessibility > AccessibleComponent


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
8 package javax.accessibility;
9
10 import java.awt.*;
11 import java.awt.event.*;
12
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     /**
37      * Gets the background color of this object.
38      *
39      * @return the background color, if supported, of the object;
40      * otherwise, null
41      * @see #setBackground
42      */

43     public Color getBackground();
44
45     /**
46      * Sets the background color of this object.
47      *
48      * @param c the new Color for the background
49      * @see #setBackground
50      */

51     public void setBackground(Color c);
52
53     /**
54      * Gets the foreground color of this object.
55      *
56      * @return the foreground color, if supported, of the object;
57      * otherwise, null
58      * @see #setForeground
59      */

60     public Color getForeground();
61
62     /**
63      * Sets the foreground color of this object.
64      *
65      * @param c the new Color for the foreground
66      * @see #getForeground
67      */

68     public void setForeground(Color c);
69
70     /**
71      * Gets the Cursor of this object.
72      *
73      * @return the Cursor, if supported, of the object; otherwise, null
74      * @see #setCursor
75      */

76     public Cursor getCursor();
77
78     /**
79      * Sets the Cursor of this object.
80      *
81      * @param cursor the new Cursor for the object
82      * @see #getCursor
83      */

84     public void setCursor(Cursor cursor);
85
86     /**
87      * Gets the Font of this object.
88      *
89      * @return the Font,if supported, for the object; otherwise, null
90      * @see #setFont
91      */

92     public Font getFont();
93
94     /**
95      * Sets the Font of this object.
96      *
97      * @param f the new Font for the object
98      * @see #getFont
99      */

100     public void setFont(Font f);
101
102     /**
103      * Gets the FontMetrics of this object.
104      *
105      * @param f the Font
106      * @return the FontMetrics, if supported, the object; otherwise, null
107      * @see #getFont
108      */

109     public FontMetrics getFontMetrics(Font f);
110
111     /**
112      * Determines if the object is enabled. Objects that are enabled
113      * will also have the AccessibleState.ENABLED state set in their
114      * AccessibleStateSets.
115      *
116      * @return true if object is enabled; otherwise, false
117      * @see #setEnabled
118      * @see AccessibleContext#getAccessibleStateSet
119      * @see AccessibleState#ENABLED
120      * @see AccessibleStateSet
121      */

122     public boolean isEnabled();
123
124     /**
125      * Sets the enabled state of the object.
126      *
127      * @param b if true, enables this object; otherwise, disables it
128      * @see #isEnabled
129      */

130     public void setEnabled(boolean b);
131
132     /**
133      * Determines if the object is visible. Note: this means that the
134      * object intends to be visible; however, it may not be
135      * showing on the screen because one of the objects that this object
136      * is contained by is currently not visible. To determine if an object is
137      * showing on the screen, use isShowing().
138      * <p>Objects that are visible will also have the
139      * AccessibleState.VISIBLE state set in their AccessibleStateSets.
140      *
141      * @return true if object is visible; otherwise, false
142      * @see #setVisible
143      * @see AccessibleContext#getAccessibleStateSet
144      * @see AccessibleState#VISIBLE
145      * @see AccessibleStateSet
146      */

147     public boolean isVisible();
148
149     /**
150      * Sets the visible state of the object.
151      *
152      * @param b if true, shows this object; otherwise, hides it
153      * @see #isVisible
154      */

155     public void setVisible(boolean b);
156
157     /**
158      * Determines if the object is showing. This is determined by checking
159      * the visibility of the object and its ancestors.
160      * Note: this
161      * will return true even if the object is obscured by another (for example,
162      * it is underneath a menu that was pulled down).
163      *
164      * @return true if object is showing; otherwise, false
165      */

166     public boolean isShowing();
167
168     /**
169      * Checks whether the specified point is within this object's bounds,
170      * where the point's x and y coordinates are defined to be relative to the
171      * coordinate system of the object.
172      *
173      * @param p the Point relative to the coordinate system of the object
174      * @return true if object contains Point; otherwise false
175      * @see #getBounds
176      */

177     public boolean contains(Point p);
178
179     /**
180      * Returns the location of the object on the screen.
181      *
182      * @return the location of the object on screen; null if this object
183      * is not on the screen
184      * @see #getBounds
185      * @see #getLocation
186      */

187     public Point getLocationOnScreen();
188
189     /**
190      * Gets the location of the object relative to the parent in the form
191      * of a point specifying the object's top-left corner in the screen's
192      * coordinate space.
193      *
194      * @return An instance of Point representing the top-left corner of the
195      * object's bounds in the coordinate space of the screen; null if
196      * this object or its parent are not on the screen
197      * @see #getBounds
198      * @see #getLocationOnScreen
199      */

200     public Point getLocation();
201
202     /**
203      * Sets the location of the object relative to the parent.
204      * @param p the new position for the top-left corner
205      * @see #getLocation
206      */

207     public void setLocation(Point p);
208
209     /**
210      * Gets the bounds of this object in the form of a Rectangle object.
211      * The bounds specify this object's width, height, and location
212      * relative to its parent.
213      *
214      * @return A rectangle indicating this component's bounds; null if
215      * this object is not on the screen.
216      * @see #contains
217      */

218     public Rectangle getBounds();
219
220     /**
221      * Sets the bounds of this object in the form of a Rectangle object.
222      * The bounds specify this object's width, height, and location
223      * relative to its parent.
224      *
225      * @param r rectangle indicating this component's bounds
226      * @see #getBounds
227      */

228     public void setBounds(Rectangle r);
229
230     /**
231      * Returns the size of this object in the form of a Dimension object.
232      * The height field of the Dimension object contains this object's
233      * height, and the width field of the Dimension object contains this
234      * object's width.
235      *
236      * @return A Dimension object that indicates the size of this component;
237      * null if this object is not on the screen
238      * @see #setSize
239      */

240     public Dimension getSize();
241
242     /**
243      * Resizes this object so that it has width and height.
244      *
245      * @param d The dimension specifying the new size of the object.
246      * @see #getSize
247      */

248     public void setSize(Dimension d);
249
250     /**
251      * Returns the Accessible child, if one exists, contained at the local
252      * coordinate Point.
253      *
254      * @param p The point relative to the coordinate system of this object.
255      * @return the Accessible, if it exists, at the specified location;
256      * otherwise null
257      */

258     public Accessible JavaDoc getAccessibleAt(Point p);
259
260     /**
261      * Returns whether this object can accept focus or not. Objects that
262      * can accept focus will also have the AccessibleState.FOCUSABLE state
263      * set in their AccessibleStateSets.
264      *
265      * @return true if object can accept focus; otherwise false
266      * @see AccessibleContext#getAccessibleStateSet
267      * @see AccessibleState#FOCUSABLE
268      * @see AccessibleState#FOCUSED
269      * @see AccessibleStateSet
270      */

271     public boolean isFocusTraversable();
272
273     /**
274      * Requests focus for this object. If this object cannot accept focus,
275      * nothing will happen. Otherwise, the object will attempt to take
276      * focus.
277      * @see #isFocusTraversable
278      */

279     public void requestFocus();
280
281     /**
282      * Adds the specified focus listener to receive focus events from this
283      * component.
284      *
285      * @param l the focus listener
286      * @see #removeFocusListener
287      */

288     public void addFocusListener(FocusListener l);
289
290     /**
291      * Removes the specified focus listener so it no longer receives focus
292      * events from this component.
293      *
294      * @param l the focus listener
295      * @see #addFocusListener
296      */

297     public void removeFocusListener(FocusListener l);
298 }
299
Popular Tags