Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

java.awt
Class MenuComponent.AccessibleAWTMenuComponent  view MenuComponent.AccessibleAWTMenuComponent download MenuComponent.AccessibleAWTMenuComponent.java

java.lang.Object
  extended byjavax.accessibility.AccessibleContext
      extended byjava.awt.MenuComponent.AccessibleAWTMenuComponent
All Implemented Interfaces:
javax.accessibility.AccessibleComponent, javax.accessibility.AccessibleSelection, java.io.Serializable
Direct Known Subclasses:
MenuBar.AccessibleAWTMenuBar, MenuItem.AccessibleAWTMenuItem
Enclosing class:
MenuComponent

protected abstract class MenuComponent.AccessibleAWTMenuComponent
extends javax.accessibility.AccessibleContext
implements java.io.Serializable, javax.accessibility.AccessibleComponent, javax.accessibility.AccessibleSelection

This class provides a base for the accessibility support of menu components.


Field Summary
private static long serialVersionUID
          Compatible with JDK 1.4.2 revision 5
 
Fields inherited from class javax.accessibility.AccessibleContext
ACCESSIBLE_ACTION_PROPERTY, ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY, ACCESSIBLE_CARET_PROPERTY, ACCESSIBLE_CHILD_PROPERTY, ACCESSIBLE_COMPONENT_BOUNDS_CHANGED, ACCESSIBLE_DESCRIPTION_PROPERTY, ACCESSIBLE_HYPERTEXT_OFFSET, ACCESSIBLE_INVALIDATE_CHILDREN, ACCESSIBLE_NAME_PROPERTY, ACCESSIBLE_SELECTION_PROPERTY, ACCESSIBLE_STATE_PROPERTY, ACCESSIBLE_TABLE_CAPTION_CHANGED, ACCESSIBLE_TABLE_COLUMN_DESCRIPTION_CHANGED, ACCESSIBLE_TABLE_COLUMN_HEADER_CHANGED, ACCESSIBLE_TABLE_MODEL_CHANGED, ACCESSIBLE_TABLE_ROW_DESCRIPTION_CHANGED, ACCESSIBLE_TABLE_ROW_HEADER_CHANGED, ACCESSIBLE_TABLE_SUMMARY_CHANGED, ACCESSIBLE_TEXT_ATTRIBUTES_CHANGED, ACCESSIBLE_TEXT_PROPERTY, ACCESSIBLE_VALUE_PROPERTY, ACCESSIBLE_VISIBLE_DATA_PROPERTY, accessibleDescription, accessibleName, accessibleParent
 
Constructor Summary
protected MenuComponent.AccessibleAWTMenuComponent()
          This is the default constructor.
 
Method Summary
 void addAccessibleSelection(int index)
          Replaces or supplements the component's selection with the Accessible child at the supplied index.
 void addFocusListener(java.awt.event.FocusListener listener)
          Registers the specified focus listener to receive focus events from this component.
 void clearAccessibleSelection()
          Clears the component's current selection.
 boolean contains(Point point)
          Returns true if the specified point lies within the component.
 javax.accessibility.Accessible getAccessibleAt(Point point)
          Returns the Accessible child of this component present at the specified point.
 javax.accessibility.Accessible getAccessibleChild(int index)
          Returns the Accessible child at the supplied index within the list of children of this component.
 int getAccessibleChildrenCount()
          Returns the number of children of this component which implement the Accessible interface.
 javax.accessibility.AccessibleComponent getAccessibleComponent()
          Retrieves the AccessibleComponent associated with this accessible context and its component.
 java.lang.String getAccessibleDescription()
          Returns the accessible name for this menu component.
 int getAccessibleIndexInParent()
          Retrieves the index of this component within its parent.
 java.lang.String getAccessibleName()
          Returns the accessible name of this component.
 javax.accessibility.Accessible getAccessibleParent()
          Returns the Accessible parent of this component.
 javax.accessibility.AccessibleRole getAccessibleRole()
          Returns the accessible role of this component.
 javax.accessibility.AccessibleSelection getAccessibleSelection()
          Retrieves the AccessibleSelection associated with this accessible context and its component.
 javax.accessibility.Accessible getAccessibleSelection(int index)
          Retrieves the Accessible selected child at the specified index.
 int getAccessibleSelectionCount()
          Returns a count of the number of Accessible children of this component which are currently selected.
 javax.accessibility.AccessibleStateSet getAccessibleStateSet()
          Retrieves the current state of this component in an accessible form.
 Color getBackground()
          Returns the background color of the component, or null if this property is unsupported.
 Rectangle getBounds()
          Returns a Rectangle which represents the bounds of this component.
 Cursor getCursor()
          Returns the Cursor displayed when the pointer is positioned over this component.
 Font getFont()
          Returns the Font used for text created by this component.
 FontMetrics getFontMetrics(Font font)
          Retrieves information on the rendering and metrics of the supplied font.
 Color getForeground()
          Returns the foreground color of the component, or null if this property is unsupported.
 java.util.Locale getLocale()
          Returns the locale currently in use by this component.
 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.
 Point getLocationOnScreen()
          Returns the location of the component, with co-ordinates relative to the screen.
 Dimension getSize()
          Returns the size of the component.
 boolean isAccessibleChildSelected(int index)
          Returns true if the accessible child specified by the supplied index is currently selected.
 boolean isEnabled()
          Returns true if this component is currently enabled.
 boolean isFocusTraversable()
          Returns true if this component is included in the traversal of the current focus from one component to the other.
 boolean isShowing()
          Returns true if the component is being shown on screen.
 boolean isVisible()
          Returns true if the component is visible.
 void removeAccessibleSelection(int index)
          Removes the accessible child specified by the supplied index from the list of currently selected children.
 void removeFocusListener(java.awt.event.FocusListener listener)
          Removes the specified focus listener from the list of registered focus listeners for this component.
 void requestFocus()
          Requests that this component gains focus.
 void selectAllAccessibleSelection()
          Selects all Accessible children of this component which it is possible to select.
 void setBackground(Color color)
          Sets the background color of the component to that specified.
 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.
 void setCursor(Cursor cursor)
          Sets the Cursor used when the pointer is positioned over the component.
 void setEnabled(boolean enabled)
          Sets the enabled/disabled state of this component.
 void setFont(Font font)
          Sets the Font used for text created by this component.
 void setForeground(Color color)
          Sets the foreground color of the component to that specified.
 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.
 void setSize(Dimension size)
          Sets the size of the component.
 void setVisible(boolean visibility)
          Sets the visibility state of the component.
 
Methods inherited from class javax.accessibility.AccessibleContext
addPropertyChangeListener, firePropertyChange, getAccessibleAction, getAccessibleEditableText, getAccessibleIcon, getAccessibleRelationSet, getAccessibleTable, getAccessibleText, getAccessibleValue, removePropertyChangeListener, setAccessibleDescription, setAccessibleName, setAccessibleParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Compatible with JDK 1.4.2 revision 5

See Also:
Constant Field Values
Constructor Detail

MenuComponent.AccessibleAWTMenuComponent

protected MenuComponent.AccessibleAWTMenuComponent()
This is the default constructor. It should be called by concrete subclasses to ensure necessary groundwork is completed.

Method Detail

addAccessibleSelection

public void addAccessibleSelection(int index)
Replaces or supplements the component's selection with the Accessible 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 javax.accessibility.AccessibleSelection

addFocusListener

public void addFocusListener(java.awt.event.FocusListener listener)
Registers the specified focus listener to receive focus events from this component.

Specified by:
addFocusListener in interface javax.accessibility.AccessibleComponent

clearAccessibleSelection

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 javax.accessibility.AccessibleSelection

contains

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 the getBounds() method. Subclasses must provide the bounding rectangle via getBounds() in order for this method to work.

Specified by:
contains in interface javax.accessibility.AccessibleComponent

getAccessibleAt

public javax.accessibility.Accessible getAccessibleAt(Point point)
Returns the Accessible 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 javax.accessibility.AccessibleComponent

getAccessibleChild

public javax.accessibility.Accessible getAccessibleChild(int index)
Returns the Accessible 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.


getAccessibleChildrenCount

public int getAccessibleChildrenCount()
Returns the number of children of this component which implement the Accessible interface. If all children of this component are accessible, then the returned value will be the same as the number of children.


getAccessibleComponent

public javax.accessibility.AccessibleComponent getAccessibleComponent()
Retrieves the AccessibleComponent associated with this accessible context and its component. As the context itself implements AccessibleComponent, this is the return value.


getAccessibleDescription

public java.lang.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 using setName().

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'.


getAccessibleIndexInParent

public int getAccessibleIndexInParent()
Retrieves the index of this component within its parent. If no parent exists, -1 is returned.


getAccessibleName

public java.lang.String getAccessibleName()
Returns the accessible name of this component. This is the name given to the component, which may be null if not set using setName().

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.


getAccessibleParent

public javax.accessibility.Accessible getAccessibleParent()
Returns the Accessible parent of this component. As the parent of a MenuComponent is a MenuContainer, which doesn't implement Accessible, this method returns null.


getAccessibleRole

public javax.accessibility.AccessibleRole getAccessibleRole()
Returns the accessible role of this component.

The abstract implementation of this method returns AccessibleRole.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.


getAccessibleSelection

public javax.accessibility.AccessibleSelection getAccessibleSelection()
Retrieves the AccessibleSelection associated with this accessible context and its component. As the context itself implements AccessibleSelection, this is the return value.


getAccessibleSelection

public javax.accessibility.Accessible getAccessibleSelection(int index)
Retrieves the Accessible 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 all Accessible 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 javax.accessibility.AccessibleSelection

getAccessibleSelectionCount

public int getAccessibleSelectionCount()
Returns a count of the number of Accessible 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 javax.accessibility.AccessibleSelection

getAccessibleStateSet

public javax.accessibility.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 using PropertyChangeListeners.


getBackground

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 javax.accessibility.AccessibleComponent

getBounds

public Rectangle getBounds()
Returns a Rectangle 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, the MenuContainer. 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 javax.accessibility.AccessibleComponent

getCursor

public Cursor getCursor()
Returns the Cursor 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 javax.accessibility.AccessibleComponent

getFont

public Font getFont()
Returns the Font used for text created by this component.

Specified by:
getFont in interface javax.accessibility.AccessibleComponent

getFontMetrics

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 the FontMetrics. Concrete subclasses may find it more efficient to invoke their peer class directly, if one is available.

Specified by:
getFontMetrics in interface javax.accessibility.AccessibleComponent

getForeground

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 javax.accessibility.AccessibleComponent

getLocale

public java.util.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.


getLocation

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 the getBounds() method. Subclasses must provide the bounding rectangle via getBounds() in order for this method to work.

Specified by:
getLocation in interface javax.accessibility.AccessibleComponent

getLocationOnScreen

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 javax.accessibility.AccessibleComponent

getSize

public Dimension getSize()
Returns the size of the component.

Please note that this method depends on a correctly implemented version of the getBounds() method. Subclasses must provide the bounding rectangle via getBounds() in order for this method to work.

Specified by:
getSize in interface javax.accessibility.AccessibleComponent

isAccessibleChildSelected

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 javax.accessibility.AccessibleSelection

isEnabled

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 javax.accessibility.AccessibleComponent

isFocusTraversable

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 javax.accessibility.AccessibleComponent

isShowing

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 javax.accessibility.AccessibleComponent

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 javax.accessibility.AccessibleComponent

removeAccessibleSelection

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 javax.accessibility.AccessibleSelection

removeFocusListener

public void removeFocusListener(java.awt.event.FocusListener listener)
Removes the specified focus listener from the list of registered focus listeners for this component.

Specified by:
removeFocusListener in interface javax.accessibility.AccessibleComponent

requestFocus

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 javax.accessibility.AccessibleComponent

selectAllAccessibleSelection

public void selectAllAccessibleSelection()
Selects all Accessible 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 uses addAccessibleSelection to add each Accessible child to the selection. The last Accessible 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 javax.accessibility.AccessibleSelection

setBackground

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 javax.accessibility.AccessibleComponent

setBounds

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 from getBounds(). 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 javax.accessibility.AccessibleComponent

setCursor

public void setCursor(Cursor cursor)
Sets the Cursor 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 javax.accessibility.AccessibleComponent

setEnabled

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 javax.accessibility.AccessibleComponent

setFont

public void setFont(Font font)
Sets the Font used for text created by this component. Unspecified behaviour occurs when null is given as the new font.

Specified by:
setFont in interface javax.accessibility.AccessibleComponent

setForeground

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 javax.accessibility.AccessibleComponent

setLocation

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 the getBounds() method. Subclasses must provide the bounding rectangle via getBounds() in order for this method to work.

Specified by:
setLocation in interface javax.accessibility.AccessibleComponent

setSize

public void setSize(Dimension size)
Sets the size of the component.

Please note that this method depends on a correctly implemented version of the getBounds() method. Subclasses must provide the bounding rectangle via getBounds() in order for this method to work.

Specified by:
setSize in interface javax.accessibility.AccessibleComponent

setVisible

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 javax.accessibility.AccessibleComponent