Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.accessibility.AccessibleContext
java.awt.MenuComponent.AccessibleAWTMenuComponent
protected abstract class MenuComponent.AccessibleAWTMenuComponent
extends AccessibleContext
implements Serializable, AccessibleComponent, AccessibleSelection
Field Summary |
Constructor Summary | |
|
Method Summary | |
void |
|
void |
|
void |
|
boolean | |
Accessible |
|
Accessible |
|
int |
|
AccessibleComponent |
|
String |
|
int |
|
String |
|
Accessible |
|
AccessibleRole |
|
AccessibleSelection |
|
Accessible |
|
int |
|
AccessibleStateSet |
|
Color |
|
Rectangle |
|
Cursor |
|
Font |
|
FontMetrics |
|
Color |
|
Locale |
|
Point |
|
Point |
|
Dimension |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void | |
void |
|
void | |
void |
|
void |
|
void | |
void |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
protected AccessibleAWTMenuComponent()
This is the default constructor. It should be called by concrete subclasses to ensure necessary groundwork is completed.
public void addAccessibleSelection(int index)
Replaces or supplements the component's selection with theAccessible
child at the supplied index. If the component supports multiple selection, the child is added to the current selection. Otherwise, the current selection becomes the specified child. If the child is already selected, nothing happens.
As the existence of children can not be determined from this abstract class, the implementation of this method is left to subclasses.
- Specified by:
- addAccessibleSelection in interface AccessibleSelection
- Parameters:
index
- the index of the specified child within a zero-based list of the component's children
public void addFocusListener(FocusListener listener)
Registers the specified focus listener to receive focus events from this component.
- Specified by:
- addFocusListener in interface AccessibleComponent
- Parameters:
listener
- the new focus listener
public void clearAccessibleSelection()
Clears the component's current selection. Following the calling of this method, no children of the component will be selected.
As the existence of children can not be determined from this abstract class, the implementation of this method is left to subclasses.
- Specified by:
- clearAccessibleSelection in interface AccessibleSelection
public boolean contains(Point point)
Returns true if the specified point lies within the component. The supplied co-ordinates are assumed to be relative to the co-ordinate system of the component itself. Thus, the point (0,0) is the upper left corner of this component.
Please note that this method depends on a correctly implemented version of thegetBounds()
method. Subclasses must provide the bounding rectangle viagetBounds()
in order for this method to work.
- Specified by:
- contains in interface AccessibleComponent
- Parameters:
point
- the point to check against this component
- Returns:
- true if the point is within this component
- See Also:
getBounds()
public Accessible getAccessibleAt(Point point)
Returns theAccessible
child of this component present at the specified point. The supplied co-ordinates are assumed to be relative to the co-ordinate system of this component (the parent of any returned accessible). Thus, the point (0,0) is the upper left corner of this menu component.
As the existence of children can not be determined from this abstract class, the implementation of this method is left to subclasses.
- Specified by:
- getAccessibleAt in interface AccessibleComponent
- Parameters:
point
- the point at which the returned accessible is located
- Returns:
- null
public Accessible getAccessibleChild(int index)
Returns theAccessible
child at the supplied index within the list of children of this component.
As the existence of children can not be determined from this abstract class, the implementation of this method is left to subclasses.
- Overrides:
- getAccessibleChild in interface AccessibleContext
- Parameters:
index
- the index of theAccessible
child to retrieve
- Returns:
- null
public int getAccessibleChildrenCount()
Returns the number of children of this component which implement theAccessible
interface. If all children of this component are accessible, then the returned value will be the same as the number of children.
- Overrides:
- getAccessibleChildrenCount in interface AccessibleContext
- Returns:
- 0
public AccessibleComponent getAccessibleComponent()
Retrieves theAccessibleComponent
associated with this accessible context and its component. As the context itself implementsAccessibleComponent
, this is the return value.
- Overrides:
- getAccessibleComponent in interface AccessibleContext
- Returns:
- the context itself
public String getAccessibleDescription()
Returns the accessible name for this menu component. This is the name given to the component, which may be null if not set usingsetName()
.
The name is not the most appropriate description of this object. Subclasses should preferably provide a more accurate description. For example, a File menu could have the description `Lists commands related to the file system'.
- Overrides:
- getAccessibleDescription in interface AccessibleContext
- Returns:
- a description of the component. Currently, this is just the contents of the name property
- See Also:
MenuComponent.setName(String)
public int getAccessibleIndexInParent()
Retrieves the index of this component within its parent. If no parent exists, -1 is returned.
- Overrides:
- getAccessibleIndexInParent in interface AccessibleContext
- Returns:
- -1 as the parent, a
MenuContainer
is notAccessible
public String getAccessibleName()
Returns the accessible name of this component. This is the name given to the component, which may be null if not set usingsetName()
.
The name property is not the most suitable string to return for this method. The string should be localized, and relevant to the operation of the component. For example, it could be the text of a menu item. However, this can not be used at this level of abstraction, so it is the responsibility of subclasses to provide a more appropriate name.
- Overrides:
- getAccessibleName in interface AccessibleContext
- Returns:
- a localized name for this component. Currently, this is just the contents of the name property
- See Also:
MenuComponent.setName(String)
public Accessible getAccessibleParent()
Returns theAccessible
parent of this component. As the parent of aMenuComponent
is aMenuContainer
, which doesn't implementAccessible
, this method returns null.
- Overrides:
- getAccessibleParent in interface AccessibleContext
- Returns:
- null
public AccessibleRole getAccessibleRole()
Returns the accessible role of this component.
The abstract implementation of this method returnsAccessibleRole.AWT_COMPONENT
, as the abstract component has no specific role. This method should be overridden by concrete subclasses, so as to return an appropriate role for the component.
- Overrides:
- getAccessibleRole in interface AccessibleContext
- Returns:
AccessibleRole.AWT_COMPONENT
public AccessibleSelection getAccessibleSelection()
Retrieves theAccessibleSelection
associated with this accessible context and its component. As the context itself implementsAccessibleSelection
, this is the return value.
- Overrides:
- getAccessibleSelection in interface AccessibleContext
- Returns:
- the context itself
public Accessible getAccessibleSelection(int index)
Retrieves theAccessible
selected child at the specified index. If there are no selected children or the index is outside the range of selected children, null is returned. Please note that the index refers to the index of the child in the list of selected children, and not the index of the child in the list of allAccessible
children.
As the existence of children can not be determined from this abstract class, the implementation of this method is left to subclasses.
- Specified by:
- getAccessibleSelection in interface AccessibleSelection
- Parameters:
index
- the index of the selectedAccessible
child
public int getAccessibleSelectionCount()
Returns a count of the number ofAccessible
children of this component which are currently selected. If there are no children currently selected, 0 is returned.
As the existence of children can not be determined from this abstract class, the implementation of this method is left to subclasses.
- Specified by:
- getAccessibleSelectionCount in interface AccessibleSelection
- Returns:
- 0
public AccessibleStateSet getAccessibleStateSet()
Retrieves the current state of this component in an accessible form. For example, a given component may be visible, selected, disabled, etc.
As this class tells us virtually nothing about the component, except for its name and font, no state information can be provided. This implementation thus returns an empty state set, and it is left to concrete subclasses to provide a more acceptable and relevant state set. Changes to these properties also need to be handled usingPropertyChangeListener
s.
- Overrides:
- getAccessibleStateSet in interface AccessibleContext
- Returns:
- an empty
AccessibleStateSet
public Color getBackground()
Returns the background color of the component, or null if this property is unsupported.
This abstract class knows nothing about how the component is drawn on screen, so this method simply returns the default system background color used for rendering menus. Concrete subclasses which handle the drawing of an onscreen menu component should override this method and provide the appropriate information.
- Specified by:
- getBackground in interface AccessibleComponent
- Returns:
- the default system background color for menus
- See Also:
setBackground(Color)
public Rectangle getBounds()
Returns aRectangle
which represents the bounds of this component. The returned rectangle has the height and width of the component's bounds, and is positioned at a location relative to this component's parent, theMenuContainer
. null is returned if bounds are not supported by the component.
This abstract class knows nothing about how the component is drawn on screen, so this method simply returns null. Concrete subclasses which handle the drawing of an onscreen menu component should override this method and provide the appropriate information.
- Specified by:
- getBounds in interface AccessibleComponent
- Returns:
- null
- See Also:
setBounds(Rectangle)
public Cursor getCursor()
Returns theCursor
displayed when the pointer is positioned over this component. Alternatively, null is returned if the component doesn't support the cursor property.
This abstract class knows nothing about how the component is drawn on screen, so this method simply returns the default system cursor. Concrete subclasses which handle the drawing of an onscreen menu component may override this method and provide the appropriate information.
- Specified by:
- getCursor in interface AccessibleComponent
- Returns:
- the default system cursor
- See Also:
setCursor(Cursor)
public Font getFont()
Returns theFont
used for text created by this component.
- Specified by:
- getFont in interface AccessibleComponent
- Returns:
- the current font
- See Also:
setFont(Font)
public FontMetrics getFontMetrics(Font font)
Retrieves information on the rendering and metrics of the supplied font. If font metrics are not supported by this component, null is returned.
The abstract implementation of this method simply uses the toolkit to obtain theFontMetrics
. Concrete subclasses may find it more efficient to invoke their peer class directly, if one is available.
- Specified by:
- getFontMetrics in interface AccessibleComponent
- Parameters:
font
- the font about which to retrieve rendering and metric information
- Returns:
- the metrics of the given font, as provided by the system toolkit
- Throws:
NullPointerException
- if the supplied font was null
public Color getForeground()
Returns the foreground color of the component, or null if this property is unsupported.
This abstract class knows nothing about how the component is drawn on screen, so this method simply returns the default system text color used for rendering menus. Concrete subclasses which handle the drawing of an onscreen menu component should override this method and provide the appropriate information.
- Specified by:
- getForeground in interface AccessibleComponent
- Returns:
- the default system text color for menus
- See Also:
setForeground(Color)
public Locale getLocale()
Returns the locale currently in use by this component.
This abstract class has no property relating to the locale used by the component, so this method simply returns the default locale for the current instance of the Java Virtual Machine (JVM). Concrete subclasses which maintain such a property should override this method and provide the locale information more accurately.
- Overrides:
- getLocale in interface AccessibleContext
- Returns:
- the default locale for this JVM instance
public Point getLocation()
Returns the location of the component, with co-ordinates relative to the parent component and using the co-ordinate space of the screen. Thus, the point (0,0) is the upper left corner of the parent component.
Please note that this method depends on a correctly implemented version of thegetBounds()
method. Subclasses must provide the bounding rectangle viagetBounds()
in order for this method to work.
- Specified by:
- getLocation in interface AccessibleComponent
- Returns:
- the location of the component, relative to its parent
- See Also:
setLocation(Point)
public Point getLocationOnScreen()
Returns the location of the component, with co-ordinates relative to the screen. Thus, the point (0,0) is the upper left corner of the screen. null is returned if the component is either not on screen or if this property is unsupported.
This abstract class knows nothing about how the component is drawn on screen, so this method simply returns null. Concrete subclasses which handle the drawing of an onscreen menu component should override this method and provide the appropriate information.
- Specified by:
- getLocationOnScreen in interface AccessibleComponent
- Returns:
- the location of the component, relative to the screen
public Dimension getSize()
Returns the size of the component.
Please note that this method depends on a correctly implemented version of thegetBounds()
method. Subclasses must provide the bounding rectangle viagetBounds()
in order for this method to work.
- Specified by:
- getSize in interface AccessibleComponent
- Returns:
- the size of the component
- See Also:
setSize(Dimension)
public boolean isAccessibleChildSelected(int index)
Returns true if the accessible child specified by the supplied index is currently selected.
As the existence of children can not be determined from this abstract class, the implementation of this method is left to subclasses.
- Specified by:
- isAccessibleChildSelected in interface AccessibleSelection
- Parameters:
index
- the index of the accessible child to check for selection
- Returns:
- false
public boolean isEnabled()
Returns true if this component is currently enabled.
As this abstract component has no properties related to its enabled or disabled state, the implementation of this method is left to subclasses.
- Specified by:
- isEnabled in interface AccessibleComponent
- Returns:
- false
- See Also:
setEnabled(boolean)
public boolean isFocusTraversable()
Returns true if this component is included in the traversal of the current focus from one component to the other.
As this abstract component has no properties related to its ability to accept the focus, the implementation of this method is left to subclasses.
- Specified by:
- isFocusTraversable in interface AccessibleComponent
- Returns:
- false
public boolean isShowing()
Returns true if the component is being shown on screen. A component is determined to be shown if it is visible, and each parent component is also visible. Please note that, even when a component is showing, it may still be obscured by other components in front. This method only determines if the component is being drawn on the screen.
As this abstract component and its parent have no properties relating to visibility, the implementation of this method is left to subclasses.
- Specified by:
- isShowing in interface AccessibleComponent
- Returns:
- false
- See Also:
isVisible()
public boolean isVisible()
Returns true if the component is visible. A component may be visible but not drawn on the screen if one of its parent components is not visible. To determine if the component is actually drawn on screen,isShowing()
should be used.
As this abstract component has no properties relating to its visibility, the implementation of this method is left to subclasses.
- Specified by:
- isVisible in interface AccessibleComponent
- Returns:
- false
- See Also:
isShowing()
,setVisible(boolean)
public void removeAccessibleSelection(int index)
Removes the accessible child specified by the supplied index from the list of currently selected children. If the child specified is not selected, nothing happens.
As the existence of children can not be determined from this abstract class, the implementation of this method is left to subclasses.
- Specified by:
- removeAccessibleSelection in interface AccessibleSelection
- Parameters:
index
- the index of theAccessible
child
public void removeFocusListener(FocusListener listener)
Removes the specified focus listener from the list of registered focus listeners for this component.
- Specified by:
- removeFocusListener in interface AccessibleComponent
- Parameters:
listener
- the listener to remove
public void requestFocus()
Requests that this component gains focus. This depends on the component being focus traversable.
As this abstract component has no properties relating to its focus traversability, or access to a peer with request focusing abilities, the implementation of this method is left to subclasses.
- Specified by:
- requestFocus in interface AccessibleComponent
public void selectAllAccessibleSelection()
Selects allAccessible
children of this component which it is possible to select. The component needs to support multiple selections.
This abstract component provides a simplistic implementation of this method, which ignores the ability of the component to support multiple selections and simply usesaddAccessibleSelection
to add eachAccessible
child to the selection. The lastAccessible
component is thus selected for components which don't support multiple selections. Concrete implementations should override this with a more appopriate and efficient implementation, which properly takes into account the ability of the component to support multiple selections.
- Specified by:
- selectAllAccessibleSelection in interface AccessibleSelection
public void setBackground(Color color)
Sets the background color of the component to that specified. Unspecified behaviour occurs when null is given as the new background color.
This abstract class knows nothing about how the component is drawn on screen, so this method simply ignores the supplied color and continues to use the default system color. Concrete subclasses which handle the drawing of an onscreen menu component should override this method and provide the appropriate information.
- Specified by:
- setBackground in interface AccessibleComponent
- Parameters:
color
- the new color to use for the background
- See Also:
getBackground()
public void setBounds(Rectangle rectangle)
Sets the height and width of the component, and its position relative to this component's parent, to the values specified by the supplied rectangle. Unspecified behaviour occurs when null is given as the new bounds.
This abstract class knows nothing about how the component is drawn on screen, so this method simply ignores the new rectangle and continues to return null fromgetBounds()
. Concrete subclasses which handle the drawing of an onscreen menu component should override this method and provide the appropriate information.
- Specified by:
- setBounds in interface AccessibleComponent
- Parameters:
rectangle
- a rectangle which specifies the new bounds of the component
- See Also:
getBounds()
public void setCursor(Cursor cursor)
Sets theCursor
used when the pointer is positioned over the component. Unspecified behaviour occurs when null is given as the new cursor.
This abstract class knows nothing about how the component is drawn on screen, so this method simply ignores the new cursor and continues to return the default system cursor. Concrete subclasses which handle the drawing of an onscreen menu component may override this method and provide the appropriate information.
- Specified by:
- setCursor in interface AccessibleComponent
- Parameters:
cursor
- the new cursor to use
- See Also:
getCursor()
public void setEnabled(boolean enabled)
Sets the enabled/disabled state of this component.
As this abstract component has no properties related to its enabled or disabled state, the implementation of this method is left to subclasses.
- Specified by:
- setEnabled in interface AccessibleComponent
- Parameters:
enabled
- true if the component should be enabled, false otherwise
- See Also:
isEnabled()
public void setFont(Font font)
Sets theFont
used for text created by this component. Unspecified behaviour occurs when null is given as the new font.
- Specified by:
- setFont in interface AccessibleComponent
- Parameters:
font
- the new font to use for text.
- See Also:
getFont()
public void setForeground(Color color)
Sets the foreground color of the component to that specified. Unspecified behaviour occurs when null is given as the new background color.
This abstract class knows nothing about how the component is drawn on screen, so this method simply ignores the supplied color and continues to return the default system text color used for rendering menus. Concrete subclasses which handle the drawing of an onscreen menu component should override this method and provide the appropriate information.
- Specified by:
- setForeground in interface AccessibleComponent
- Parameters:
color
- the new foreground color
- See Also:
getForeground()
public void setLocation(Point point)
Sets the location of the component, with co-ordinates relative to the parent component and using the co-ordinate space of the screen. Thus, the point (0,0) is the upper left corner of the parent component.
Please note that this method depends on a correctly implemented version of thegetBounds()
method. Subclasses must provide the bounding rectangle viagetBounds()
in order for this method to work.
- Specified by:
- setLocation in interface AccessibleComponent
- Parameters:
point
- the location of the component, relative to its parent
- See Also:
getLocation()
public void setSize(Dimension size)
Sets the size of the component.
Please note that this method depends on a correctly implemented version of thegetBounds()
method. Subclasses must provide the bounding rectangle viagetBounds()
in order for this method to work.
- Specified by:
- setSize in interface AccessibleComponent
- Parameters:
size
- the new size of the component
- See Also:
getSize()
public void setVisible(boolean visibility)
Sets the visibility state of the component. A component may be visible but not drawn on the screen if one of its parent components is not visible. To determine if the component is actually drawn on screen,isShowing()
should be used.
As this abstract component has no properties relating to its visibility, the implementation of this method is left to subclasses.
- Specified by:
- setVisible in interface AccessibleComponent
- Parameters:
visibility
- the new visibility of the component -- true if the component is visible, false if not
- See Also:
isShowing()
,isVisible()