java.lang.Object
javax.accessibility.AccessibleContext
com.sun.java.accessibility.util.Translator
- All Implemented Interfaces:
- Accessible,- AccessibleComponent
public class Translator extends AccessibleContext implements 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 SummaryFields Modifier and Type Field Description protected ObjectsourceThe source object needing translating.Fields declared in class javax.accessibility.AccessibleContextACCESSIBLE_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 SummaryConstructors Constructor Description Translator()Create a newTranslator.Translator(Object o)Create a newTranslatorwith the source object o.
- 
Method SummaryModifier and Type Method Description voidaddFocusListener(FocusListener l)Adds the specifiedFocusListenerto receive focus events from this component.voidaddPropertyChangeListener(PropertyChangeListener l)Add aPropertyChangeListenerto the listener list.booleancontains(Point p)Checks whether the specifiedPointis within this object's bounds, where thePointis relative to the coordinate system of the object.booleanequals(Object o)Returns true if this object is the same as the one passed in.static AccessiblegetAccessible(Object o)Obtain an object that implements interfaceAccessible.AccessiblegetAccessibleAt(Point p)Returns the accessible child contained at the local coordinate Point, if one exists.AccessiblegetAccessibleChild(int i)Return the nth accessible child of the object.intgetAccessibleChildrenCount()Returns the number of accessible children in the object.AccessibleContextgetAccessibleContext()Returns this object.StringgetAccessibleDescription()Get the accessible description of this object.intgetAccessibleIndexInParent()Get the index of this object in its accessible parent.StringgetAccessibleName()Get the accessible name of this object.AccessiblegetAccessibleParent()Get the accessible parent of this object.AccessibleRolegetAccessibleRole()Get the role of this object.AccessibleStateSetgetAccessibleStateSet()Get the state of this object, given an already populated state.ColorgetBackground()Get the backgroundColorof this object.RectanglegetBounds()Returns the current bounds of this object.CursorgetCursor()Get theCursorof this object.FontgetFont()Get theFontof this object.FontMetricsgetFontMetrics(Font f)Get theFontMetricsof this object.ColorgetForeground()Get the foregroundColorof this object.LocalegetLocale()Gets theLocaleof the component.PointgetLocation()Returns the location of the object relative to parent.PointgetLocationOnScreen()Returns the location of the object on the screen.DimensiongetSize()Returns the current size of this object.ObjectgetSource()Get the sourceObjectof theTranslator.protected static Class<?>getTranslatorClass(Class<?> c)Find a translator for this class.inthashCode()Return hashcode.booleanisEnabled()Determine if the object is enabled.booleanisFocusTraversable()Returns whether this object can accept focus or not.booleanisShowing()Determine if the object is showing.booleanisVisible()Determine if the object is visible.voidremoveFocusListener(FocusListener l)Removes the specified focus listener so it no longer receives focus events from this component.voidremovePropertyChangeListener(PropertyChangeListener l)Remove thePropertyChangeListenerfrom the listener list.voidrequestFocus()Requests focus for this object.voidsetAccessibleDescription(String s)Set the accessible description of this object.voidsetAccessibleName(String s)Set the name of this object.voidsetBackground(Color c)Set the backgroundColorof this object.voidsetBounds(Rectangle r)Sets the current bounds of this object.voidsetCursor(Cursor c)Set theCursorof this object.voidsetEnabled(boolean b)Set the enabled state of the object.voidsetFont(Font f)Set theFontof this object.voidsetForeground(Color c)Set the foregroundColorof this object.voidsetLocation(Point p)Sets the location of the object relative to parent.voidsetSize(Dimension d)Sets the current size of this object.voidsetSource(Object o)Set the source object of theTranslator.voidsetVisible(boolean b)Set the visible state of the object.Methods declared in class javax.accessibility.AccessibleContextfirePropertyChange, getAccessibleAction, getAccessibleComponent, getAccessibleEditableText, getAccessibleIcon, getAccessibleRelationSet, getAccessibleSelection, getAccessibleTable, getAccessibleText, getAccessibleValue, setAccessibleParent
- 
Field Details- 
sourceThe source object needing translating.
 
- 
- 
Constructor Details- 
Translatorpublic Translator()Create a newTranslator. You must call thesetSourcemethod to set the object to be translated after calling this constructor.
- 
TranslatorCreate a newTranslatorwith the source object o.- Parameters:
- o- the Component that does not implement interface- Accessible
 
 
- 
- 
Method Details- 
getTranslatorClassFind 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
 
- 
getAccessibleObtain 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
 
- 
getSourceGet the sourceObjectof theTranslator.- Returns:
- the source Objectof theTranslator
 
- 
setSourceSet the source object of theTranslator.- Parameters:
- o- the Component that does not implement interface Accessible
 
- 
equalsReturns true if this object is the same as the one passed in.- Overrides:
- equalsin class- Object
- Parameters:
- o- the- Objectto check against
- Returns:
- true if this is the same object
- See Also:
- Object.hashCode(),- HashMap
 
- 
hashCodepublic int hashCode()Return hashcode.- Overrides:
- hashCodein class- Object
- Returns:
- hashcode
- See Also:
- Object.equals(java.lang.Object),- System.identityHashCode(java.lang.Object)
 
- 
getAccessibleContextReturns this object.- Specified by:
- getAccessibleContextin interface- Accessible
- Returns:
- the AccessibleContextassociated with this object
 
- 
getAccessibleNameGet the accessible name of this object.- Overrides:
- getAccessibleNamein class- AccessibleContext
- Returns:
- the localized name of the object; can be null if this object does not have a name
- See Also:
- AccessibleContext.setAccessibleName(java.lang.String)
 
- 
setAccessibleNameSet the name of this object.- Overrides:
- setAccessibleNamein class- AccessibleContext
- Parameters:
- s- the new localized name of the object
- See Also:
- AccessibleContext.getAccessibleName(),- AccessibleContext.addPropertyChangeListener(java.beans.PropertyChangeListener)
 
- 
getAccessibleDescriptionGet the accessible description of this object.- Overrides:
- getAccessibleDescriptionin class- AccessibleContext
- Returns:
- the description of the object; can be null if this object does not have a description
- See Also:
- AccessibleContext.setAccessibleDescription(java.lang.String)
 
- 
setAccessibleDescriptionSet the accessible description of this object.- Overrides:
- setAccessibleDescriptionin class- AccessibleContext
- Parameters:
- s- the new localized description of the object
- See Also:
- AccessibleContext.setAccessibleName(java.lang.String),- AccessibleContext.addPropertyChangeListener(java.beans.PropertyChangeListener)
 
- 
getAccessibleRoleGet the role of this object.- Specified by:
- getAccessibleRolein class- AccessibleContext
- Returns:
- an instance of AccessibleRole describing the role of the object
- See Also:
- AccessibleRole
 
- 
getAccessibleStateSetGet 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 class- AccessibleContext
- Returns:
- an instance of AccessibleStateSetcontaining the current state of the object
- See Also:
- AccessibleStateSet,- AccessibleState,- AccessibleContext.addPropertyChangeListener(java.beans.PropertyChangeListener)
 
- 
getAccessibleParentGet the accessible parent of this object.- Overrides:
- getAccessibleParentin class- AccessibleContext
- Returns:
- the accessible parent of this object; can be null if this object does not have an accessible parent
 
- 
getAccessibleIndexInParentpublic int getAccessibleIndexInParent()Get the index of this object in its accessible parent.- Specified by:
- getAccessibleIndexInParentin class- AccessibleContext
- Returns:
- -1 of this object does not have an accessible parent; otherwise, the index of the child in its accessible parent
- See Also:
- AccessibleContext.getAccessibleParent(),- AccessibleContext.getAccessibleChildrenCount(),- AccessibleContext.getAccessibleChild(int)
 
- 
getAccessibleChildrenCountpublic int getAccessibleChildrenCount()Returns the number of accessible children in the object.- Specified by:
- getAccessibleChildrenCountin class- AccessibleContext
- Returns:
- the number of accessible children in the object
 
- 
getAccessibleChildReturn the nth accessible child of the object.- Specified by:
- getAccessibleChildin class- AccessibleContext
- Parameters:
- i- zero-based index of child
- Returns:
- the nth accessible child of the object
- See Also:
- AccessibleContext.getAccessibleChildrenCount()
 
- 
getLocaleGets theLocaleof the component. If the component does not have a locale, the locale of its parent is returned.- Specified by:
- getLocalein class- AccessibleContext
- 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
 
- 
addPropertyChangeListenerAdd aPropertyChangeListenerto the listener list. The listener is registered for all properties.- Overrides:
- addPropertyChangeListenerin class- AccessibleContext
- Parameters:
- l- The PropertyChangeListener to be added
- See Also:
- AccessibleContext.ACCESSIBLE_NAME_PROPERTY,- AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY,- AccessibleContext.ACCESSIBLE_STATE_PROPERTY,- AccessibleContext.ACCESSIBLE_VALUE_PROPERTY,- AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY,- AccessibleContext.ACCESSIBLE_TEXT_PROPERTY,- AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY
 
- 
removePropertyChangeListenerRemove thePropertyChangeListenerfrom the listener list.- Overrides:
- removePropertyChangeListenerin class- AccessibleContext
- Parameters:
- l- The PropertyChangeListener to be removed
 
- 
getBackgroundGet the backgroundColorof this object.- Specified by:
- getBackgroundin interface- AccessibleComponent
- Returns:
- if supported, the background Colorof the object; otherwise, null
- See Also:
- AccessibleComponent.setBackground(java.awt.Color)
 
- 
setBackgroundSet the backgroundColorof this object.- Specified by:
- setBackgroundin interface- AccessibleComponent
- Parameters:
- c- the new- Colorfor the background
- See Also:
- AccessibleComponent.setBackground(java.awt.Color)
 
- 
getForegroundGet the foregroundColorof this object.- Specified by:
- getForegroundin interface- AccessibleComponent
- Returns:
- if supported, the foreground Colorof the object; otherwise, null
- See Also:
- AccessibleComponent.setForeground(java.awt.Color)
 
- 
setForegroundSet the foregroundColorof this object.- Specified by:
- setForegroundin interface- AccessibleComponent
- Parameters:
- c- the new- Colorfor the foreground
- See Also:
- AccessibleComponent.getForeground()
 
- 
getCursorGet theCursorof this object.- Specified by:
- getCursorin interface- AccessibleComponent
- Returns:
- if supported, the Cursor of the object; otherwise, null
- See Also:
- AccessibleComponent.setCursor(java.awt.Cursor)
 
- 
setCursorSet theCursorof this object.- Specified by:
- setCursorin interface- AccessibleComponent
- Parameters:
- c- the new- Cursorfor the object
- See Also:
- AccessibleComponent.getCursor()
 
- 
getFontGet theFontof this object.- Specified by:
- getFontin interface- AccessibleComponent
- Returns:
- if supported, the Fontfor the object; otherwise, null
- See Also:
- AccessibleComponent.setFont(java.awt.Font)
 
- 
setFontSet theFontof this object.- Specified by:
- setFontin interface- AccessibleComponent
- Parameters:
- f- the new- Fontfor the object
- See Also:
- AccessibleComponent.getFont()
 
- 
getFontMetricsGet theFontMetricsof this object.- Specified by:
- getFontMetricsin interface- AccessibleComponent
- Parameters:
- f- the- Font
- Returns:
- if supported, the FontMetricsthe object; otherwise, null
- See Also:
- getFont()
 
- 
isEnabledpublic boolean isEnabled()Determine if the object is enabled.- Specified by:
- isEnabledin interface- AccessibleComponent
- Returns:
- true if object is enabled; otherwise, false
- See Also:
- AccessibleComponent.setEnabled(boolean),- AccessibleContext.getAccessibleStateSet(),- AccessibleState.ENABLED,- AccessibleStateSet
 
- 
setEnabledpublic void setEnabled(boolean b)Set the enabled state of the object.- Specified by:
- setEnabledin interface- AccessibleComponent
- Parameters:
- b- if true, enables this object; otherwise, disables it
- See Also:
- AccessibleComponent.isEnabled()
 
- 
isVisiblepublic boolean isVisible()Determine if the object is visible.- Specified by:
- isVisiblein interface- AccessibleComponent
- Returns:
- true if object is visible; otherwise, false
- See Also:
- AccessibleComponent.setVisible(boolean),- AccessibleContext.getAccessibleStateSet(),- AccessibleState.VISIBLE,- AccessibleStateSet
 
- 
setVisiblepublic void setVisible(boolean b)Set the visible state of the object.- Specified by:
- setVisiblein interface- AccessibleComponent
- Parameters:
- b- if true, shows this object; otherwise, hides it
- See Also:
- AccessibleComponent.isVisible()
 
- 
isShowingpublic 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 interface- AccessibleComponent
- Returns:
- true if object is showing; otherwise, false
 
- 
containsChecks whether the specifiedPointis within this object's bounds, where thePointis relative to the coordinate system of the object.- Specified by:
- containsin interface- AccessibleComponent
- Parameters:
- p- the- Pointrelative to the coordinate system of the object
- Returns:
- true if object contains Point; otherwise false
- See Also:
- AccessibleComponent.getBounds()
 
- 
getLocationOnScreenReturns the location of the object on the screen.- Specified by:
- getLocationOnScreenin interface- AccessibleComponent
- Returns:
- location of object on screen; can be null if this object is not on the screen
- See Also:
- AccessibleComponent.getBounds(),- AccessibleComponent.getLocation()
 
- 
getLocationReturns the location of the object relative to parent.- Specified by:
- getLocationin interface- AccessibleComponent
- Returns:
- location of object relative to parent; can be null if this object or its parent are not on the screen
- See Also:
- AccessibleComponent.getBounds(),- AccessibleComponent.getLocationOnScreen()
 
- 
setLocationSets the location of the object relative to parent.- Specified by:
- setLocationin interface- AccessibleComponent
- Parameters:
- p- the new position for the top-left corner
- See Also:
- AccessibleComponent.getLocation()
 
- 
getBoundsReturns the current bounds of this object.- Specified by:
- getBoundsin interface- AccessibleComponent
- Returns:
- current bounds of object; can be null if this object is not on the screen
- See Also:
- AccessibleComponent.contains(java.awt.Point)
 
- 
setBoundsSets the current bounds of this object.- Specified by:
- setBoundsin interface- AccessibleComponent
- Parameters:
- r- rectangle indicating this component's bounds
- See Also:
- AccessibleComponent.getBounds()
 
- 
getSizeReturns the current size of this object.- Specified by:
- getSizein interface- AccessibleComponent
- Returns:
- current size of object; can be null if this object is not on the screen
- See Also:
- AccessibleComponent.setSize(java.awt.Dimension)
 
- 
setSizeSets the current size of this object.- Specified by:
- setSizein interface- AccessibleComponent
- Parameters:
- d- The dimension specifying the new size of the object
- See Also:
- AccessibleComponent.getSize()
 
- 
getAccessibleAtReturns the accessible child contained at the local coordinate Point, if one exists.- Specified by:
- getAccessibleAtin interface- AccessibleComponent
- Parameters:
- p- The point relative to the coordinate system of this object
- Returns:
- the Accessible at the specified location, if it exists
 
- 
isFocusTraversablepublic boolean isFocusTraversable()Returns whether this object can accept focus or not.- Specified by:
- isFocusTraversablein interface- AccessibleComponent
- Returns:
- true if object can accept focus; otherwise false
- See Also:
- AccessibleContext.getAccessibleStateSet(),- AccessibleState.FOCUSABLE,- AccessibleState.FOCUSED,- AccessibleStateSet
 
- 
requestFocuspublic void requestFocus()Requests focus for this object.- Specified by:
- requestFocusin interface- AccessibleComponent
- See Also:
- AccessibleComponent.isFocusTraversable()
 
- 
addFocusListenerAdds the specifiedFocusListenerto receive focus events from this component.- Specified by:
- addFocusListenerin interface- AccessibleComponent
- Parameters:
- l- the focus listener
- See Also:
- AccessibleComponent.removeFocusListener(java.awt.event.FocusListener)
 
- 
removeFocusListenerRemoves the specified focus listener so it no longer receives focus events from this component.- Specified by:
- removeFocusListenerin interface- AccessibleComponent
- 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:
- AccessibleComponent.addFocusListener(java.awt.event.FocusListener)
 
 
-