public interface AccessibleComponent
The AccessibleComponent interface should be supported by any object that is rendered on the screen. This interface provides the standard mechanism for an assistive technology to determine and set the graphical representation of an object. Applications can determine if an object supports the AccessibleComponent interface by first obtaining its AccessibleContext and then calling the AccessibleContext.getAccessibleComponent()
method. If the return value is not null, the object supports this interface.
Accessible
, Accessible.getAccessibleContext()
, AccessibleContext
, AccessibleContext.getAccessibleComponent()
Color getBackground()
Gets the background color of this object.
setBackground(java.awt.Color)
void setBackground(Color c)
Sets the background color of this object.
c
- the new Color for the backgroundsetBackground(java.awt.Color)
Color getForeground()
Gets the foreground color of this object.
setForeground(java.awt.Color)
void setForeground(Color c)
Sets the foreground color of this object.
c
- the new Color for the foregroundgetForeground()
Cursor getCursor()
Gets the Cursor of this object.
setCursor(java.awt.Cursor)
void setCursor(Cursor cursor)
Sets the Cursor of this object.
cursor
- the new Cursor for the objectgetCursor()
Font getFont()
Gets the Font of this object.
setFont(java.awt.Font)
void setFont(Font f)
Sets the Font of this object.
f
- the new Font for the objectgetFont()
FontMetrics getFontMetrics(Font f)
Gets the FontMetrics of this object.
f
- the FontgetFont()
boolean isEnabled()
Determines if the object is enabled. Objects that are enabled will also have the AccessibleState.ENABLED state set in their AccessibleStateSets.
setEnabled(boolean)
, AccessibleContext.getAccessibleStateSet()
, AccessibleState.ENABLED
, AccessibleStateSet
void setEnabled(boolean b)
Sets the enabled state of the object.
b
- if true, enables this object; otherwise, disables itisEnabled()
boolean isVisible()
Determines if the object is visible. Note: this means that the object intends to be visible; however, it may not be showing on the screen because one of the objects that this object is contained by is currently not visible. To determine if an object is showing on the screen, use isShowing().
Objects that are visible will also have the AccessibleState.VISIBLE state set in their AccessibleStateSets.
setVisible(boolean)
, AccessibleContext.getAccessibleStateSet()
, AccessibleState.VISIBLE
, AccessibleStateSet
void setVisible(boolean b)
Sets the visible state of the object.
b
- if true, shows this object; otherwise, hides itisVisible()
boolean isShowing()
Determines if the object is showing. This is determined by checking the visibility of the object and its ancestors. Note: this will return true even if the object is obscured by another (for example, it is underneath a menu that was pulled down).
boolean contains(Point p)
Checks whether the specified point is within this object's bounds, where the point's x and y coordinates are defined to be relative to the coordinate system of the object.
p
- the Point relative to the coordinate system of the objectgetBounds()
Point getLocationOnScreen()
Returns the location of the object on the screen.
getBounds()
, getLocation()
Point getLocation()
Gets the location of the object relative to the parent in the form of a point specifying the object's top-left corner in the screen's coordinate space.
getBounds()
, getLocationOnScreen()
void setLocation(Point p)
Sets the location of the object relative to the parent.
p
- the new position for the top-left cornergetLocation()
Rectangle getBounds()
Gets the bounds of this object in the form of a Rectangle object. The bounds specify this object's width, height, and location relative to its parent.
contains(java.awt.Point)
void setBounds(Rectangle r)
Sets the bounds of this object in the form of a Rectangle object. The bounds specify this object's width, height, and location relative to its parent.
r
- rectangle indicating this component's boundsgetBounds()
Dimension getSize()
Returns the size of this object in the form of a Dimension object. The height field of the Dimension object contains this object's height, and the width field of the Dimension object contains this object's width.
setSize(java.awt.Dimension)
void setSize(Dimension d)
Resizes this object so that it has width and height.
d
- The dimension specifying the new size of the object.getSize()
Accessible getAccessibleAt(Point p)
Returns the Accessible child, if one exists, contained at the local coordinate Point.
p
- The point relative to the coordinate system of this object.boolean isFocusTraversable()
Returns whether this object can accept focus or not. Objects that can accept focus will also have the AccessibleState.FOCUSABLE state set in their AccessibleStateSets.
AccessibleContext.getAccessibleStateSet()
, AccessibleState.FOCUSABLE
, AccessibleState.FOCUSED
, AccessibleStateSet
void requestFocus()
Requests focus for this object. If this object cannot accept focus, nothing will happen. Otherwise, the object will attempt to take focus.
isFocusTraversable()
void addFocusListener(FocusListener l)
Adds the specified focus listener to receive focus events from this component.
l
- the focus listenerremoveFocusListener(java.awt.event.FocusListener)
void removeFocusListener(FocusListener l)
Removes the specified focus listener so it no longer receives focus events from this component.
l
- the focus listeneraddFocusListener(java.awt.event.FocusListener)
© 1993–2017, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.