java.lang.Object
javax.accessibility.AccessibleContext
com.sun.java.accessibility.util.Translator
- All Implemented Interfaces:
Accessible,AccessibleComponent
The Translator class provides a translation to interface
Accessible
for objects that do not implement interface Accessible. Assistive
technologies can use the getAccessible class method of
Translator to obtain an object that implements interface Accessible.
If the object passed in already implements interface Accessible,
getAccessible merely returns the object.
An example of how an assistive technology might use the Translator
class is as follows:
Accessible accessible = Translator.getAccessible(someObj);
// obtain information from the 'accessible' object.
Note: This implementation is missing many things and is not a recommended way
to implement accessibility features for a toolkit. Instead of relying upon this
code, a toolkit's components should implement interface Accessible directly.
-
Field Summary
FieldsFields declared in 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
ConstructorsConstructorDescriptionCreate a newTranslator.Translator(Object o) Create a newTranslatorwith the source object o. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the specifiedFocusListenerto receive focus events from this component.voidAdd aPropertyChangeListenerto the listener list.booleanChecks whether the specifiedPointis within this object's bounds, where thePointis relative to the coordinate system of the object.booleanReturns true if this object is the same as the one passed in.static AccessibleObtain an object that implements interfaceAccessible.Returns the accessible child contained at the local coordinate Point, if one exists.getAccessibleChild(int i) Return the nth accessible child of the object.intReturns the number of accessible children in the object.Returns this object.Get the accessible description of this object.intGet the index of this object in its accessible parent.Get the accessible name of this object.Get the accessible parent of this object.Get the role of this object.Get the state of this object, given an already populated state.Get the backgroundColorof this object.Returns the current bounds of this object.Get theCursorof this object.getFont()Get theFontof this object.Get theFontMetricsof this object.Get the foregroundColorof this object.Gets theLocaleof the component.Returns the location of the object relative to parent.Returns the location of the object on the screen.getSize()Returns the current size of this object.Get the sourceObjectof theTranslator.protected static Class<?>getTranslatorClass(Class<?> c) Find a translator for this class.inthashCode()Return hashcode.booleanDetermine if the object is enabled.booleanReturns whether this object can accept focus or not.booleanDetermine if the object is showing.booleanDetermine if the object is visible.voidRemoves the specified focus listener so it no longer receives focus events from this component.voidRemove thePropertyChangeListenerfrom the listener list.voidRequests focus for this object.voidSet the accessible description of this object.voidSet the name of this object.voidSet the backgroundColorof this object.voidSets the current bounds of this object.voidSet theCursorof this object.voidsetEnabled(boolean b) Set the enabled state of the object.voidSet theFontof this object.voidSet the foregroundColorof this object.voidsetLocation(Point p) Sets the location of the object relative to parent.voidSets the current size of this object.voidSet the source object of theTranslator.voidsetVisible(boolean b) Set the visible state of the object.Methods declared in class javax.accessibility.AccessibleContext
firePropertyChange, getAccessibleAction, getAccessibleComponent, getAccessibleEditableText, getAccessibleIcon, getAccessibleRelationSet, getAccessibleSelection, getAccessibleTable, getAccessibleText, getAccessibleValue, setAccessibleParent
-
Field Details
-
source
The source object needing translating.
-
-
Constructor Details
-
Translator
public Translator()Create a newTranslator. You must call thesetSourcemethod to set the object to be translated after calling this constructor. -
Translator
Create a newTranslatorwith the source object o.- Parameters:
o- the Component that does not implement interfaceAccessible
-
-
Method Details
-
getTranslatorClass
Find a translator for this class. If one doesn't exist for this class explicitly, try its superclass and so on.- Parameters:
c- a Class- Returns:
- the
TranslatorClass for the Class passed in
-
getAccessible
Obtain an object that implements interfaceAccessible. If the object passed in already implements interfaceAccessible,getAccessiblemerely returns the object.- Parameters:
o- an Object; if a null is passed in a null is returned- Returns:
- an
Object, possibly theObjectpassed in, that implements theAccessibleinterface for theObjectwhich was passed in
-
getSource
Get the sourceObjectof theTranslator.- Returns:
- the source
Objectof theTranslator
-
setSource
Set the source object of theTranslator.- Parameters:
o- the Component that does not implement interface Accessible
-
equals
Returns true if this object is the same as the one passed in. -
hashCode
public int hashCode()Return hashcode. -
getAccessibleContext
Returns this object.- Specified by:
getAccessibleContextin interfaceAccessible- Returns:
- the
AccessibleContextassociated with this object
-
getAccessibleName
Get the accessible name of this object.- Overrides:
getAccessibleNamein classAccessibleContext- Returns:
- the localized name of the object; can be null if this object does not have a name
- See Also:
-
setAccessibleName
Set the name of this object.- Overrides:
setAccessibleNamein classAccessibleContext- Parameters:
s- the new localized name of the object- See Also:
-
getAccessibleDescription
Get the accessible description of this object.- Overrides:
getAccessibleDescriptionin classAccessibleContext- Returns:
- the description of the object; can be null if this object does not have a description
- See Also:
-
setAccessibleDescription
Set the accessible description of this object.- Overrides:
setAccessibleDescriptionin classAccessibleContext- Parameters:
s- the new localized description of the object- See Also:
-
getAccessibleRole
Get the role of this object.- Specified by:
getAccessibleRolein classAccessibleContext- Returns:
- an instance of AccessibleRole describing the role of the object
- See Also:
-
getAccessibleStateSet
Get the state of this object, given an already populated state. This method is intended for use by subclasses so they don't have to check for everything.- Specified by:
getAccessibleStateSetin classAccessibleContext- Returns:
- an instance of
AccessibleStateSetcontaining the current state of the object - See Also:
-
getAccessibleParent
Get the accessible parent of this object.- Overrides:
getAccessibleParentin classAccessibleContext- Returns:
- the accessible parent of this object; can be null if this object does not have an accessible parent
-
getAccessibleIndexInParent
public int getAccessibleIndexInParent()Get the index of this object in its accessible parent.- Specified by:
getAccessibleIndexInParentin classAccessibleContext- Returns:
- -1 of this object does not have an accessible parent; otherwise, the index of the child in its accessible parent
- See Also:
-
getAccessibleChildrenCount
public int getAccessibleChildrenCount()Returns the number of accessible children in the object.- Specified by:
getAccessibleChildrenCountin classAccessibleContext- Returns:
- the number of accessible children in the object
-
getAccessibleChild
Return the nth accessible child of the object.- Specified by:
getAccessibleChildin classAccessibleContext- Parameters:
i- zero-based index of child- Returns:
- the nth accessible child of the object
- See Also:
-
getLocale
Gets theLocaleof the component. If the component does not have a locale, the locale of its parent is returned.- Specified by:
getLocalein classAccessibleContext- Returns:
- the
Localeof the object - Throws:
IllegalComponentStateException- If the component does not have its own locale and has not yet been added to a containment hierarchy such that the locale can be determined from the containing parent
-
addPropertyChangeListener
Add aPropertyChangeListenerto the listener list. The listener is registered for all properties.- Overrides:
addPropertyChangeListenerin classAccessibleContext- Parameters:
l- The PropertyChangeListener to be added- See Also:
-
AccessibleContext.ACCESSIBLE_NAME_PROPERTYAccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTYAccessibleContext.ACCESSIBLE_STATE_PROPERTYAccessibleContext.ACCESSIBLE_VALUE_PROPERTYAccessibleContext.ACCESSIBLE_SELECTION_PROPERTYAccessibleContext.ACCESSIBLE_TEXT_PROPERTYAccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY
-
removePropertyChangeListener
Remove thePropertyChangeListenerfrom the listener list.- Overrides:
removePropertyChangeListenerin classAccessibleContext- Parameters:
l- The PropertyChangeListener to be removed
-
getBackground
Get the backgroundColorof this object.- Specified by:
getBackgroundin interfaceAccessibleComponent- Returns:
- if supported, the background
Colorof the object; otherwise, null - See Also:
-
setBackground
Set the backgroundColorof this object.- Specified by:
setBackgroundin interfaceAccessibleComponent- Parameters:
c- the newColorfor the background- See Also:
-
getForeground
Get the foregroundColorof this object.- Specified by:
getForegroundin interfaceAccessibleComponent- Returns:
- if supported, the foreground
Colorof the object; otherwise, null - See Also:
-
setForeground
Set the foregroundColorof this object.- Specified by:
setForegroundin interfaceAccessibleComponent- Parameters:
c- the newColorfor the foreground- See Also:
-
getCursor
Get theCursorof this object.- Specified by:
getCursorin interfaceAccessibleComponent- Returns:
- if supported, the Cursor of the object; otherwise, null
- See Also:
-
setCursor
Set theCursorof this object.- Specified by:
setCursorin interfaceAccessibleComponent- Parameters:
c- the newCursorfor the object- See Also:
-
getFont
Get theFontof this object.- Specified by:
getFontin interfaceAccessibleComponent- Returns:
- if supported, the
Fontfor the object; otherwise, null - See Also:
-
setFont
Set theFontof this object.- Specified by:
setFontin interfaceAccessibleComponent- Parameters:
f- the newFontfor the object- See Also:
-
getFontMetrics
Get theFontMetricsof this object.- Specified by:
getFontMetricsin interfaceAccessibleComponent- Parameters:
f- theFont- Returns:
- if supported, the
FontMetricsthe object; otherwise, null - See Also:
-
isEnabled
public boolean isEnabled()Determine if the object is enabled.- Specified by:
isEnabledin interfaceAccessibleComponent- Returns:
- true if object is enabled; otherwise, false
- See Also:
-
setEnabled
public void setEnabled(boolean b) Set the enabled state of the object.- Specified by:
setEnabledin interfaceAccessibleComponent- Parameters:
b- if true, enables this object; otherwise, disables it- See Also:
-
isVisible
public boolean isVisible()Determine if the object is visible.- Specified by:
isVisiblein interfaceAccessibleComponent- Returns:
- true if object is visible; otherwise, false
- See Also:
-
setVisible
public void setVisible(boolean b) Set the visible state of the object.- Specified by:
setVisiblein interfaceAccessibleComponent- Parameters:
b- if true, shows this object; otherwise, hides it- See Also:
-
isShowing
public boolean isShowing()Determine if the object is showing. This is determined by checking the visibility of the object and ancestors of the object.- Specified by:
isShowingin interfaceAccessibleComponent- Returns:
- true if object is showing; otherwise, false
-
contains
Checks whether the specifiedPointis within this object's bounds, where thePointis relative to the coordinate system of the object.- Specified by:
containsin interfaceAccessibleComponent- Parameters:
p- thePointrelative to the coordinate system of the object- Returns:
- true if object contains
Point; otherwise false - See Also:
-
getLocationOnScreen
Returns the location of the object on the screen.- Specified by:
getLocationOnScreenin interfaceAccessibleComponent- Returns:
- location of object on screen; can be null if this object is not on the screen
- See Also:
-
getLocation
Returns the location of the object relative to parent.- Specified by:
getLocationin interfaceAccessibleComponent- Returns:
- location of object relative to parent; can be null if this object or its parent are not on the screen
- See Also:
-
setLocation
Sets the location of the object relative to parent.- Specified by:
setLocationin interfaceAccessibleComponent- Parameters:
p- the new position for the top-left corner- See Also:
-
getBounds
Returns the current bounds of this object.- Specified by:
getBoundsin interfaceAccessibleComponent- Returns:
- current bounds of object; can be null if this object is not on the screen
- See Also:
-
setBounds
Sets the current bounds of this object.- Specified by:
setBoundsin interfaceAccessibleComponent- Parameters:
r- rectangle indicating this component's bounds- See Also:
-
getSize
Returns the current size of this object.- Specified by:
getSizein interfaceAccessibleComponent- Returns:
- current size of object; can be null if this object is not on the screen
- See Also:
-
setSize
Sets the current size of this object.- Specified by:
setSizein interfaceAccessibleComponent- Parameters:
d- The dimension specifying the new size of the object- See Also:
-
getAccessibleAt
Returns the accessible child contained at the local coordinate Point, if one exists.- Specified by:
getAccessibleAtin interfaceAccessibleComponent- Parameters:
p- The point relative to the coordinate system of this object- Returns:
- the Accessible at the specified location, if it exists
-
isFocusTraversable
public boolean isFocusTraversable()Returns whether this object can accept focus or not.- Specified by:
isFocusTraversablein interfaceAccessibleComponent- Returns:
- true if object can accept focus; otherwise false
- See Also:
-
requestFocus
public void requestFocus()Requests focus for this object.- Specified by:
requestFocusin interfaceAccessibleComponent- See Also:
-
addFocusListener
Adds the specifiedFocusListenerto receive focus events from this component.- Specified by:
addFocusListenerin interfaceAccessibleComponent- Parameters:
l- the focus listener- See Also:
-
removeFocusListener
Removes the specified focus listener so it no longer receives focus events from this component.- Specified by:
removeFocusListenerin interfaceAccessibleComponent- Parameters:
l- the focus listener; this method performs no function, nor does it throw an exception if the listener specified was not previously added to this component; if listener is null, no exception is thrown and no action is performed.- See Also:
-