APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.java.accessibility.util

public Class Translator

extends AccessibleContext
implements Accessible, AccessibleComponent
Class Inheritance
All Implemented Interfaces
javax.accessibility.AccessibleComponent, javax.accessibility.Accessible
Known Direct Subclasses
com.sun.java.accessibility.util.internal.ButtonTranslator, com.sun.java.accessibility.util.internal.CheckboxTranslator, com.sun.java.accessibility.util.internal.LabelTranslator, com.sun.java.accessibility.util.internal.ListTranslator, com.sun.java.accessibility.util.internal.TextComponentTranslator
Imports
com.sun.java.accessibility.util.internal.*, java.beans.*, java.util.*, java.awt.*, java.awt.event.*, javax.accessibility.*

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

Modifier and TypeField and Description
protected Object
source

The source object needing translating.

Inherited from javax.accessibility.AccessibleContext:
ACCESSIBLE_ACTION_PROPERTYACCESSIBLE_ACTIVE_DESCENDANT_PROPERTYACCESSIBLE_CARET_PROPERTYACCESSIBLE_CHILD_PROPERTYACCESSIBLE_COMPONENT_BOUNDS_CHANGEDACCESSIBLE_DESCRIPTION_PROPERTYACCESSIBLE_HYPERTEXT_OFFSETACCESSIBLE_INVALIDATE_CHILDRENACCESSIBLE_NAME_PROPERTYACCESSIBLE_SELECTION_PROPERTYACCESSIBLE_STATE_PROPERTYACCESSIBLE_TABLE_CAPTION_CHANGEDACCESSIBLE_TABLE_COLUMN_DESCRIPTION_CHANGEDACCESSIBLE_TABLE_COLUMN_HEADER_CHANGEDACCESSIBLE_TABLE_MODEL_CHANGEDACCESSIBLE_TABLE_ROW_DESCRIPTION_CHANGEDACCESSIBLE_TABLE_ROW_HEADER_CHANGEDACCESSIBLE_TABLE_SUMMARY_CHANGEDACCESSIBLE_TEXT_ATTRIBUTES_CHANGEDACCESSIBLE_TEXT_PROPERTYACCESSIBLE_VALUE_PROPERTYACCESSIBLE_VISIBLE_DATA_PROPERTYaccessibleDescriptionaccessibleNameaccessibleParent

Constructor Summary

AccessConstructor and Description
public
Translator()

Create a new Translator.

public
Translator(Object
the Component that does not implement interface Accessible
o
)

Create a new Translator with the source object o.

Method Summary

Modifier and TypeMethod and Description
public synchronized void
addFocusListener(FocusListener
the focus listener
l
)

Implements javax.accessibility.AccessibleComponent.addFocusListener.

Adds the specified FocusListener to receive focus events from this component.

public void
public boolean

Returns:

true if object contains Point; otherwise false
contains
(Point
the Point relative to the coordinate system of the object
p
)

Implements javax.accessibility.AccessibleComponent.contains.

Checks whether the specified Point is within this object's bounds, where the Point is relative to the coordinate system of the object.

public boolean

Returns:

true if this is the same object
equals
(Object
the Object to check against
o
)

Overrides java.lang.Object.equals.

Returns true if this object is the same as the one passed in.

public static Accessible

Returns:

an Object, possibly the Object passed in, that implements the Accessible interface for the Object which was passed in
getAccessible
(Object
an Object; if a null is passed in a null is returned
o
)

Obtain an object that implements interface Accessible.

public Accessible

Returns:

the Accessible at the specified location, if it exists
getAccessibleAt
(Point p)

Implements javax.accessibility.AccessibleComponent.getAccessibleAt.

Returns the accessible child contained at the local coordinate Point, if one exists.

public Accessible

Returns:

the nth accessible child of the object
getAccessibleChild
(int
zero-based index of child
i
)

Implements abstract javax.accessibility.AccessibleContext.getAccessibleChild.

Return the nth accessible child of the object.

public int

Returns:

the number of accessible children in the object
getAccessibleChildrenCount
()

Implements abstract javax.accessibility.AccessibleContext.getAccessibleChildrenCount.

Returns the number of accessible children in the object.

public AccessibleContext
public String

Returns:

the description of the object; can be null if this object does not have a description
getAccessibleDescription
()

Overrides javax.accessibility.AccessibleContext.getAccessibleDescription.

Get the accessible description of this object.

public int

Returns:

-1 of this object does not have an accessible parent; otherwise, the index of the child in its accessible parent
getAccessibleIndexInParent
()

Implements abstract javax.accessibility.AccessibleContext.getAccessibleIndexInParent.

Get the index of this object in its accessible parent.

public String

Returns:

the localized name of the object; can be null if this object does not have a name
getAccessibleName
()

Overrides javax.accessibility.AccessibleContext.getAccessibleName.

Get the accessible name of this object.

public Accessible

Returns:

the accessible parent of this object; can be null if this object does not have an accessible parent
getAccessibleParent
()

Overrides javax.accessibility.AccessibleContext.getAccessibleParent.

Get the accessible parent of this object.

public AccessibleRole

Returns:

an instance of AccessibleRole describing the role of the object
getAccessibleRole
()

Implements abstract javax.accessibility.AccessibleContext.getAccessibleRole.

Get the role of this object.

public AccessibleStateSet

Returns:

an instance of AccessibleStateSet containing the current state of the object
getAccessibleStateSet
()

Implements abstract javax.accessibility.AccessibleContext.getAccessibleStateSet.

Get the state of this object, given an already populated state.

public Color

Returns:

if supported, the background Color of the object; otherwise, null
getBackground
()

Implements javax.accessibility.AccessibleComponent.getBackground.

Get the background Color of this object.

public Rectangle

Returns:

current bounds of object; can be null if this object is not on the screen
getBounds
()

Implements javax.accessibility.AccessibleComponent.getBounds.

Returns the current bounds of this object.

public Cursor

Returns:

if supported, the Cursor of the object; otherwise, null
getCursor
()

Implements javax.accessibility.AccessibleComponent.getCursor.

Get the Cursor of this object.

public Font

Returns:

if supported, the Font for the object; otherwise, null
getFont
()

Implements javax.accessibility.AccessibleComponent.getFont.

Get the Font of this object.

public FontMetrics

Returns:

if supported, the FontMetrics the object; otherwise, null
getFontMetrics
(Font
the Font
f
)

Implements javax.accessibility.AccessibleComponent.getFontMetrics.

Get the FontMetrics of this object.

public Color

Returns:

if supported, the foreground Color of the object; otherwise, null
getForeground
()

Implements javax.accessibility.AccessibleComponent.getForeground.

Get the foreground Color of this object.

public Locale

Returns:

the Locale of the object
getLocale
()

Implements abstract javax.accessibility.AccessibleContext.getLocale.

Gets the Locale of the component.

public Point

Returns:

location of object relative to parent; can be null if this object or its parent are not on the screen
getLocation
()

Implements javax.accessibility.AccessibleComponent.getLocation.

Returns the location of the object relative to parent.

public Point

Returns:

location of object on screen; can be null if this object is not on the screen
getLocationOnScreen
()

Implements javax.accessibility.AccessibleComponent.getLocationOnScreen.

Returns the location of the object on the screen.

public Dimension

Returns:

current size of object; can be null if this object is not on the screen
getSize
()

Implements javax.accessibility.AccessibleComponent.getSize.

Returns the current size of this object.

public Object

Returns:

the source Object of the Translator
getSource
()

Get the source Object of the Translator.

protected static Class<?>

Returns:

the Translator Class for the Class passed in
getTranslatorClass
(Class<?>
a Class
c
)

Find a translator for this class.

public int

Returns:

hashcode
hashCode
()

Overrides java.lang.Object.hashCode.

Return hashcode.

public boolean

Returns:

true if object is enabled; otherwise, false
isEnabled
()

Implements javax.accessibility.AccessibleComponent.isEnabled.

Determine if the object is enabled.

public boolean

Returns:

true if object can accept focus; otherwise false
isFocusTraversable
()

Implements javax.accessibility.AccessibleComponent.isFocusTraversable.

Returns whether this object can accept focus or not.

public boolean

Returns:

true if object is showing; otherwise, false
isShowing
()

Implements javax.accessibility.AccessibleComponent.isShowing.

Determine if the object is showing.

public boolean

Returns:

true if object is visible; otherwise, false
isVisible
()

Implements javax.accessibility.AccessibleComponent.isVisible.

Determine if the object is visible.

public synchronized void
removeFocusListener(FocusListener
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.
l
)

Implements javax.accessibility.AccessibleComponent.removeFocusListener.

Removes the specified focus listener so it no longer receives focus events from this component.

public void
public void
requestFocus()

Implements javax.accessibility.AccessibleComponent.requestFocus.

Requests focus for this object.

public void
setAccessibleDescription(String
the new localized description of the object
s
)

Overrides javax.accessibility.AccessibleContext.setAccessibleDescription.

Set the accessible description of this object.

public void
public void
setBackground(Color
the new Color for the background
c
)

Implements javax.accessibility.AccessibleComponent.setBackground.

Set the background Color of this object.

public void
setBounds(Rectangle r)

Implements javax.accessibility.AccessibleComponent.setBounds.

Sets the current bounds of this object.

public void
setCursor(Cursor
the new Cursor for the object
c
)

Implements javax.accessibility.AccessibleComponent.setCursor.

Set the Cursor of this object.

public void
setEnabled(boolean
if true, enables this object; otherwise, disables it
b
)

Implements javax.accessibility.AccessibleComponent.setEnabled.

Set the enabled state of the object.

public void
setFont(Font
the new Font for the object
f
)

Implements javax.accessibility.AccessibleComponent.setFont.

Set the Font of this object.

public void
setForeground(Color
the new Color for the foreground
c
)

Implements javax.accessibility.AccessibleComponent.setForeground.

Set the foreground Color of this object.

public void
setLocation(Point p)

Implements javax.accessibility.AccessibleComponent.setLocation.

Sets the location of the object relative to parent.

public void
setSize(Dimension d)

Implements javax.accessibility.AccessibleComponent.setSize.

Sets the current size of this object.

public void
setSource(Object
the Component that does not implement interface Accessible
o
)

Set the source object of the Translator.

public void
setVisible(boolean
if true, shows this object; otherwise, hides it
b
)

Implements javax.accessibility.AccessibleComponent.setVisible.

Set the visible state of the object.

Inherited from javax.accessibility.AccessibleContext:
firePropertyChangegetAccessibleActiongetAccessibleComponentgetAccessibleEditableTextgetAccessibleIcongetAccessibleRelationSetgetAccessibleSelectiongetAccessibleTablegetAccessibleTextgetAccessibleValuesetAccessibleParent

Field Detail

sourceback to summary
protected Object source

The source object needing translating.

Constructor Detail

Translatorback to summary
public Translator()

Create a new Translator. You must call the setSource method to set the object to be translated after calling this constructor.

Translatorback to summary
public Translator(Object o)

Create a new Translator with the source object o.

Parameters
o:Object

the Component that does not implement interface Accessible

Method Detail

addFocusListenerback to summary
public synchronized void addFocusListener(FocusListener l)

Implements javax.accessibility.AccessibleComponent.addFocusListener.

Adds the specified FocusListener to receive focus events from this component.

Parameters
l:FocusListener

the focus listener

addPropertyChangeListenerback to summary
public void addPropertyChangeListener(PropertyChangeListener l)

Overrides javax.accessibility.AccessibleContext.addPropertyChangeListener.

Add a PropertyChangeListener to the listener list. The listener is registered for all properties.

containsback to summary
public boolean contains(Point p)

Implements javax.accessibility.AccessibleComponent.contains.

Checks whether the specified Point is within this object's bounds, where the Point is relative to the coordinate system of the object.

Parameters
p:Point

the Point relative to the coordinate system of the object

Returns:boolean

true if object contains Point; otherwise false

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Returns true if this object is the same as the one passed in.

Parameters
o:Object

the Object to check against

Returns:boolean

true if this is the same object

getAccessibleback to summary
public static Accessible getAccessible(Object o)

Obtain an object that implements interface Accessible. If the object passed in already implements interface Accessible, getAccessible merely returns the object.

Parameters
o:Object

an Object; if a null is passed in a null is returned

Returns:Accessible

an Object, possibly the Object passed in, that implements the Accessible interface for the Object which was passed in

getAccessibleAtback to summary
public Accessible getAccessibleAt(Point p)

Implements javax.accessibility.AccessibleComponent.getAccessibleAt.

Returns the accessible child contained at the local coordinate Point, if one exists.

Returns:Accessible

the Accessible at the specified location, if it exists

getAccessibleChildback to summary
public Accessible getAccessibleChild(int i)

Implements abstract javax.accessibility.AccessibleContext.getAccessibleChild.

Return the nth accessible child of the object.

Parameters
i:int

zero-based index of child

Returns:Accessible

the nth accessible child of the object

getAccessibleChildrenCountback to summary
public int getAccessibleChildrenCount()

Implements abstract javax.accessibility.AccessibleContext.getAccessibleChildrenCount.

Returns the number of accessible children in the object.

Returns:int

the number of accessible children in the object

getAccessibleContextback to summary
public AccessibleContext getAccessibleContext()

Implements javax.accessibility.Accessible.getAccessibleContext.

Returns this object.

getAccessibleDescriptionback to summary
public String getAccessibleDescription()

Overrides javax.accessibility.AccessibleContext.getAccessibleDescription.

Get the accessible description of this object.

Returns:String

the description of the object; can be null if this object does not have a description

getAccessibleIndexInParentback to summary
public int getAccessibleIndexInParent()

Implements abstract javax.accessibility.AccessibleContext.getAccessibleIndexInParent.

Get the index of this object in its accessible parent.

Returns:int

-1 of this object does not have an accessible parent; otherwise, the index of the child in its accessible parent

getAccessibleNameback to summary
public String getAccessibleName()

Overrides javax.accessibility.AccessibleContext.getAccessibleName.

Get the accessible name of this object.

Returns:String

the localized name of the object; can be null if this object does not have a name

getAccessibleParentback to summary
public Accessible getAccessibleParent()

Overrides javax.accessibility.AccessibleContext.getAccessibleParent.

Get the accessible parent of this object.

Returns:Accessible

the accessible parent of this object; can be null if this object does not have an accessible parent

getAccessibleRoleback to summary
public AccessibleRole getAccessibleRole()

Implements abstract javax.accessibility.AccessibleContext.getAccessibleRole.

Get the role of this object.

Returns:AccessibleRole

an instance of AccessibleRole describing the role of the object

getAccessibleStateSetback to summary
public AccessibleStateSet getAccessibleStateSet()

Implements abstract javax.accessibility.AccessibleContext.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.

Returns:AccessibleStateSet

an instance of AccessibleStateSet containing the current state of the object

getBackgroundback to summary
public Color getBackground()

Implements javax.accessibility.AccessibleComponent.getBackground.

Get the background Color of this object.

Returns:Color

if supported, the background Color of the object; otherwise, null

getBoundsback to summary
public Rectangle getBounds()

Implements javax.accessibility.AccessibleComponent.getBounds.

Returns the current bounds of this object.

Returns:Rectangle

current bounds of object; can be null if this object is not on the screen

getCursorback to summary
public Cursor getCursor()

Implements javax.accessibility.AccessibleComponent.getCursor.

Get the Cursor of this object.

Returns:Cursor

if supported, the Cursor of the object; otherwise, null

getFontback to summary
public Font getFont()

Implements javax.accessibility.AccessibleComponent.getFont.

Get the Font of this object.

Returns:Font

if supported, the Font for the object; otherwise, null

getFontMetricsback to summary
public FontMetrics getFontMetrics(Font f)

Implements javax.accessibility.AccessibleComponent.getFontMetrics.

Get the FontMetrics of this object.

Parameters
f:Font

the Font

Returns:FontMetrics

if supported, the FontMetrics the object; otherwise, null

See Also
getFont
getForegroundback to summary
public Color getForeground()

Implements javax.accessibility.AccessibleComponent.getForeground.

Get the foreground Color of this object.

Returns:Color

if supported, the foreground Color of the object; otherwise, null

getLocaleback to summary
public Locale getLocale() throws IllegalComponentStateException

Implements abstract javax.accessibility.AccessibleContext.getLocale.

Gets the Locale of the component. If the component does not have a locale, the locale of its parent is returned.

Returns:Locale

the Locale of the object

Exceptions
IllegalComponentStateException:

Doc from javax.accessibility.AccessibleContext.getLocale.

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

getLocationback to summary
public Point getLocation()

Implements javax.accessibility.AccessibleComponent.getLocation.

Returns the location of the object relative to parent.

Returns:Point

location of object relative to parent; can be null if this object or its parent are not on the screen

getLocationOnScreenback to summary
public Point getLocationOnScreen()

Implements javax.accessibility.AccessibleComponent.getLocationOnScreen.

Returns the location of the object on the screen.

Returns:Point

location of object on screen; can be null if this object is not on the screen

getSizeback to summary
public Dimension getSize()

Implements javax.accessibility.AccessibleComponent.getSize.

Returns the current size of this object.

Returns:Dimension

current size of object; can be null if this object is not on the screen

getSourceback to summary
public Object getSource()

Get the source Object of the Translator.

Returns:Object

the source Object of the Translator

getTranslatorClassback to summary
protected static Class<?> getTranslatorClass(Class<?> c)

Find a translator for this class. If one doesn't exist for this class explicitly, try its superclass and so on.

Parameters
c:Class<?>

a Class

Returns:Class<?>

the Translator Class for the Class passed in

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Return hashcode.

Returns:int

hashcode

isEnabledback to summary
public boolean isEnabled()

Implements javax.accessibility.AccessibleComponent.isEnabled.

Determine if the object is enabled.

Returns:boolean

true if object is enabled; otherwise, false

isFocusTraversableback to summary
public boolean isFocusTraversable()

Implements javax.accessibility.AccessibleComponent.isFocusTraversable.

Returns whether this object can accept focus or not.

Returns:boolean

true if object can accept focus; otherwise false

Annotations
@SuppressWarnings:deprecation
isShowingback to summary
public boolean isShowing()

Implements javax.accessibility.AccessibleComponent.isShowing.

Determine if the object is showing. This is determined by checking the visibility of the object and ancestors of the object.

Returns:boolean

true if object is showing; otherwise, false

isVisibleback to summary
public boolean isVisible()

Implements javax.accessibility.AccessibleComponent.isVisible.

Determine if the object is visible.

Returns:boolean

true if object is visible; otherwise, false

removeFocusListenerback to summary
public synchronized void removeFocusListener(FocusListener l)

Implements javax.accessibility.AccessibleComponent.removeFocusListener.

Removes the specified focus listener so it no longer receives focus events from this component.

Parameters
l:FocusListener

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.

removePropertyChangeListenerback to summary
public void removePropertyChangeListener(PropertyChangeListener l)

Overrides javax.accessibility.AccessibleContext.removePropertyChangeListener.

Remove the PropertyChangeListener from the listener list.

requestFocusback to summary
public void requestFocus()

Implements javax.accessibility.AccessibleComponent.requestFocus.

Requests focus for this object.

setAccessibleDescriptionback to summary
public void setAccessibleDescription(String s)

Overrides javax.accessibility.AccessibleContext.setAccessibleDescription.

Set the accessible description of this object.

Parameters
s:String

the new localized description of the object

setAccessibleNameback to summary
public void setAccessibleName(String s)

Overrides javax.accessibility.AccessibleContext.setAccessibleName.

Set the name of this object.

setBackgroundback to summary
public void setBackground(Color c)

Implements javax.accessibility.AccessibleComponent.setBackground.

Set the background Color of this object.

Parameters
c:Color

the new Color for the background

setBoundsback to summary
public void setBounds(Rectangle r)

Implements javax.accessibility.AccessibleComponent.setBounds.

Sets the current bounds of this object.

setCursorback to summary
public void setCursor(Cursor c)

Implements javax.accessibility.AccessibleComponent.setCursor.

Set the Cursor of this object.

Parameters
c:Cursor

the new Cursor for the object

setEnabledback to summary
public void setEnabled(boolean b)

Implements javax.accessibility.AccessibleComponent.setEnabled.

Set the enabled state of the object.

Parameters
b:boolean

if true, enables this object; otherwise, disables it

setFontback to summary
public void setFont(Font f)

Implements javax.accessibility.AccessibleComponent.setFont.

Set the Font of this object.

Parameters
f:Font

the new Font for the object

setForegroundback to summary
public void setForeground(Color c)

Implements javax.accessibility.AccessibleComponent.setForeground.

Set the foreground Color of this object.

Parameters
c:Color

the new Color for the foreground

setLocationback to summary
public void setLocation(Point p)

Implements javax.accessibility.AccessibleComponent.setLocation.

Sets the location of the object relative to parent.

setSizeback to summary
public void setSize(Dimension d)

Implements javax.accessibility.AccessibleComponent.setSize.

Sets the current size of this object.

setSourceback to summary
public void setSource(Object o)

Set the source object of the Translator.

Parameters
o:Object

the Component that does not implement interface Accessible

setVisibleback to summary
public void setVisible(boolean b)

Implements javax.accessibility.AccessibleComponent.setVisible.

Set the visible state of the object.

Parameters
b:boolean

if true, shows this object; otherwise, hides it