1 |
/* SwingUtilities.java -- |
/* SwingUtilities.java -- |
2 |
Copyright (C) 2002, 2004 Free Software Foundation, Inc. |
Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
59 |
import java.awt.event.MouseEvent; |
import java.awt.event.MouseEvent; |
60 |
import java.lang.reflect.InvocationTargetException; |
import java.lang.reflect.InvocationTargetException; |
61 |
|
|
62 |
|
import javax.accessibility.Accessible; |
63 |
|
import javax.accessibility.AccessibleStateSet; |
64 |
import javax.swing.plaf.ActionMapUIResource; |
import javax.swing.plaf.ActionMapUIResource; |
65 |
import javax.swing.plaf.InputMapUIResource; |
import javax.swing.plaf.InputMapUIResource; |
66 |
|
|
70 |
* regions which need painting. |
* regions which need painting. |
71 |
* |
* |
72 |
* @author Graydon Hoare (graydon@redhat.com) |
* @author Graydon Hoare (graydon@redhat.com) |
73 |
|
* @author Andrew John Hughes (gnu_andrew@member.fsf.org) |
74 |
*/ |
*/ |
75 |
public class SwingUtilities implements SwingConstants |
public class SwingUtilities |
76 |
|
implements SwingConstants |
77 |
{ |
{ |
78 |
/** |
/** |
79 |
* This frame should be used as parent for JWindow or JDialog |
* This frame should be used as parent for JWindow or JDialog |
165 |
} |
} |
166 |
|
|
167 |
/** |
/** |
168 |
|
* Returns the <code>Accessible</code> child of the specified component |
169 |
|
* which appears at the supplied <code>Point</code>. If there is no |
170 |
|
* child located at that particular pair of co-ordinates, null is returned |
171 |
|
* instead. |
172 |
|
* |
173 |
|
* @param c the component whose children may be found at the specified |
174 |
|
* point. |
175 |
|
* @param p the point at which to look for the existence of children |
176 |
|
* of the specified component. |
177 |
|
* @return the <code>Accessible</code> child at the point, <code>p</code>, |
178 |
|
* or null if there is no child at this point. |
179 |
|
* @see javax.accessibility.AccessibleComponent#getAccessibleAt |
180 |
|
*/ |
181 |
|
public static Accessible getAccessibleAt(Component c, Point p) |
182 |
|
{ |
183 |
|
return c.getAccessibleContext().getAccessibleComponent().getAccessibleAt(p); |
184 |
|
} |
185 |
|
|
186 |
|
/** |
187 |
|
* <p> |
188 |
|
* Returns the <code>Accessible</code> child of the specified component |
189 |
|
* that has the supplied index within the parent component. The indexing |
190 |
|
* of the children is zero-based, making the first child have an index of |
191 |
|
* 0. |
192 |
|
* </p> |
193 |
|
* <p> |
194 |
|
* Caution is advised when using this method, as its operation relies |
195 |
|
* on the behaviour of varying implementations of an abstract method. |
196 |
|
* For greater surety, direct use of the AWT component implementation |
197 |
|
* of this method is advised. |
198 |
|
* </p> |
199 |
|
* |
200 |
|
* @param c the component whose child should be returned. |
201 |
|
* @param i the index of the child within the parent component. |
202 |
|
* @return the <code>Accessible</code> child at index <code>i</code> |
203 |
|
* in the component, <code>c</code>. |
204 |
|
* @see javax.accessibility.AccessibleContext#getAccessibleChild |
205 |
|
* @see java.awt.Component.AccessibleAWTComponent#getAccessibleChild |
206 |
|
*/ |
207 |
|
public static Accessible getAccessibleChild(Component c, int i) |
208 |
|
{ |
209 |
|
return c.getAccessibleContext().getAccessibleChild(i); |
210 |
|
} |
211 |
|
|
212 |
|
/** |
213 |
|
* <p> |
214 |
|
* Returns the number of <code>Accessible</code> children within |
215 |
|
* the supplied component. |
216 |
|
* </p> |
217 |
|
* <p> |
218 |
|
* Caution is advised when using this method, as its operation relies |
219 |
|
* on the behaviour of varying implementations of an abstract method. |
220 |
|
* For greater surety, direct use of the AWT component implementation |
221 |
|
* of this method is advised. |
222 |
|
* </p> |
223 |
|
* |
224 |
|
* @param c the component whose children should be counted. |
225 |
|
* @return the number of children belonging to the component, |
226 |
|
* <code>c</code>. |
227 |
|
* @see javax.accessibility.AccessibleContext#getAccessibleChildrenCount |
228 |
|
* @see java.awt.Component.AccessibleAWTComponent#getAccessibleChildrenCount |
229 |
|
*/ |
230 |
|
public static int getAccessibleChildrenCount(Component c) |
231 |
|
{ |
232 |
|
return c.getAccessibleContext().getAccessibleChildrenCount(); |
233 |
|
} |
234 |
|
|
235 |
|
/** |
236 |
|
* <p> |
237 |
|
* Returns the zero-based index of the specified component |
238 |
|
* within its parent. If the component doesn't have a parent, |
239 |
|
* -1 is returned. |
240 |
|
* </p> |
241 |
|
* <p> |
242 |
|
* Caution is advised when using this method, as its operation relies |
243 |
|
* on the behaviour of varying implementations of an abstract method. |
244 |
|
* For greater surety, direct use of the AWT component implementation |
245 |
|
* of this method is advised. |
246 |
|
* </p> |
247 |
|
* |
248 |
|
* @param c the component whose parental index should be found. |
249 |
|
* @return the index of the component within its parent, or -1 |
250 |
|
* if the component doesn't have a parent. |
251 |
|
* @see javax.accessibility.AccessibleContext#getAccessibleIndexInParent |
252 |
|
* @see java.awt.Component.AccessibleAWTComponent#getAccessibleIndexInParent |
253 |
|
*/ |
254 |
|
public static int getAccessibleIndexInParent(Component c) |
255 |
|
{ |
256 |
|
return c.getAccessibleContext().getAccessibleIndexInParent(); |
257 |
|
} |
258 |
|
|
259 |
|
/** |
260 |
|
* <p> |
261 |
|
* Returns a set of <code>AccessibleState</code>s, which represent |
262 |
|
* the state of the supplied component. |
263 |
|
* </p> |
264 |
|
* <p> |
265 |
|
* Caution is advised when using this method, as its operation relies |
266 |
|
* on the behaviour of varying implementations of an abstract method. |
267 |
|
* For greater surety, direct use of the AWT component implementation |
268 |
|
* of this method is advised. |
269 |
|
* </p> |
270 |
|
* |
271 |
|
* @param c the component whose accessible state should be retrieved. |
272 |
|
* @return a set of <code>AccessibleState</code> objects, which represent |
273 |
|
* the state of the supplied component. |
274 |
|
* @see javax.accessibility.AccessibleContext#getAccessibleStateSet |
275 |
|
* @see java.awt.Component.AccessibleAWTComponent#getAccessibleStateSet |
276 |
|
*/ |
277 |
|
public static AccessibleStateSet getAccessibleStateSet(Component c) |
278 |
|
{ |
279 |
|
return c.getAccessibleContext().getAccessibleStateSet(); |
280 |
|
} |
281 |
|
|
282 |
|
/** |
283 |
* Calculates the bounds of a component in the component's own coordinate |
* Calculates the bounds of a component in the component's own coordinate |
284 |
* space. The result has the same height and width as the component's |
* space. The result has the same height and width as the component's |
285 |
* bounds, but its location is set to (0,0). |
* bounds, but its location is set to (0,0). |