@Exported 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.
Modifier and Type | Field and Description |
---|---|
protected Object |
source
The source object needing translating.
|
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 and Description |
---|
Translator()
Create a new
Translator . |
Translator(Object o)
Create a new
Translator with the source object o. |
Modifier and Type | Method and Description |
---|---|
void |
addFocusListener(FocusListener l)
Adds the specified
FocusListener to receive focus events from
this component. |
void |
addPropertyChangeListener(PropertyChangeListener l)
Add a
PropertyChangeListener to the listener list. |
boolean |
contains(Point p)
Checks whether the specified
Point is within this
object's bounds, where the Point is relative to the coordinate
system of the object. |
boolean |
equals(Object o)
Returns true if this object is the same as the one passed in.
|
static Accessible |
getAccessible(Object o)
Obtain an object that implements interface
Accessible . |
Accessible |
getAccessibleAt(Point p)
Returns the accessible child contained at the local coordinate
Point, if one exists.
|
Accessible |
getAccessibleChild(int i)
Return the nth accessible child of the object.
|
int |
getAccessibleChildrenCount()
Returns the number of accessible children in the object.
|
AccessibleContext |
getAccessibleContext()
Returns this object.
|
String |
getAccessibleDescription()
Get the accessible description of this object.
|
int |
getAccessibleIndexInParent()
Get the index of this object in its accessible parent.
|
String |
getAccessibleName()
Get the accessible name of this object.
|
Accessible |
getAccessibleParent()
Get the accessible parent of this object.
|
AccessibleRole |
getAccessibleRole()
Get the role of this object.
|
AccessibleStateSet |
getAccessibleStateSet()
Get the state of this object, given an already populated state.
|
Color |
getBackground()
Get the background
Color of this object. |
Rectangle |
getBounds()
Returns the current bounds of this object.
|
Cursor |
getCursor()
Get the
Cursor of this object. |
Font |
getFont()
Get the
Font of this object. |
FontMetrics |
getFontMetrics(Font f)
Get the
FontMetrics of this object. |
Color |
getForeground()
Get the foreground
Color of this object. |
Locale |
getLocale()
Gets the
Locale of the component. |
Point |
getLocation()
Returns the location of the object relative to parent.
|
Point |
getLocationOnScreen()
Returns the location of the object on the screen.
|
Dimension |
getSize()
Returns the current size of this object.
|
Object |
getSource()
Get the source
Object of the Translator . |
protected static Class |
getTranslatorClass(Class c)
Find a translator for this class.
|
boolean |
isEnabled()
Determine if the object is enabled.
|
boolean |
isFocusTraversable()
Returns whether this object can accept focus or not.
|
boolean |
isShowing()
Determine if the object is showing.
|
boolean |
isVisible()
Determine if the object is visible.
|
void |
removeFocusListener(FocusListener l)
Removes the specified focus listener so it no longer receives focus
events from this component.
|
void |
removePropertyChangeListener(PropertyChangeListener l)
Remove the
PropertyChangeListener from the listener list. |
void |
requestFocus()
Requests focus for this object.
|
void |
setAccessibleDescription(String s)
Set the accessible description of this object.
|
void |
setAccessibleName(String s)
Set the name of this object.
|
void |
setBackground(Color c)
Set the background
Color of this object. |
void |
setBounds(Rectangle r)
Sets the current bounds of this object.
|
void |
setCursor(Cursor c)
Set the
Cursor of this object. |
void |
setEnabled(boolean b)
Set the enabled state of the object.
|
void |
setFont(Font f)
Set the
Font of this object. |
void |
setForeground(Color c)
Set the foreground
Color of this object. |
void |
setLocation(Point p)
Sets the location of the object relative to parent.
|
void |
setSize(Dimension d)
Sets the current size of this object.
|
void |
setSource(Object o)
Set the source object of the
Translator . |
void |
setVisible(boolean b)
Set the visible state of the object.
|
firePropertyChange, getAccessibleAction, getAccessibleComponent, getAccessibleEditableText, getAccessibleIcon, getAccessibleRelationSet, getAccessibleSelection, getAccessibleTable, getAccessibleText, getAccessibleValue, setAccessibleParent
protected Object source
public Translator()
Translator
. You must call the setSource
method to set the object to be translated after calling this constructor.public Translator(Object o)
Translator
with the source object o.o
- the Component that does not implement interface
Accessible
protected static Class getTranslatorClass(Class c)
c
- a ClassTranslator
Class for the Class passed inpublic static Accessible getAccessible(Object o)
Accessible
. If the object
passed in already implements interface Accessible
, getAccessible
merely returns the object.o
- an Object; if a null is passed in a null is returnedObject
, possibly the Object
passed in, that
implements the Accessible
interface for the Object
which was passed inpublic Object getSource()
Object
of the Translator
.Object
of the Translator
public void setSource(Object o)
Translator
.o
- the Component that does not implement interface Accessiblepublic boolean equals(Object o)
equals
in class Object
o
- the Object
to check againstObject.hashCode()
,
HashMap
public AccessibleContext getAccessibleContext()
getAccessibleContext
in interface Accessible
public String getAccessibleName()
getAccessibleName
in class AccessibleContext
AccessibleContext.setAccessibleName(java.lang.String)
public void setAccessibleName(String s)
setAccessibleName
in class AccessibleContext
s
- the new localized name of the object.AccessibleContext.getAccessibleName()
,
AccessibleContext.addPropertyChangeListener(java.beans.PropertyChangeListener)
public String getAccessibleDescription()
getAccessibleDescription
in class AccessibleContext
AccessibleContext.setAccessibleDescription(java.lang.String)
public void setAccessibleDescription(String s)
setAccessibleDescription
in class AccessibleContext
s
- the new localized description of the objectAccessibleContext.setAccessibleName(java.lang.String)
,
AccessibleContext.addPropertyChangeListener(java.beans.PropertyChangeListener)
public AccessibleRole getAccessibleRole()
getAccessibleRole
in class AccessibleContext
AccessibleRole
public AccessibleStateSet getAccessibleStateSet()
getAccessibleStateSet
in class AccessibleContext
AccessibleStateSet
containing the current state of the objectAccessibleStateSet
,
AccessibleState
,
AccessibleContext.addPropertyChangeListener(java.beans.PropertyChangeListener)
public Accessible getAccessibleParent()
getAccessibleParent
in class AccessibleContext
public int getAccessibleIndexInParent()
getAccessibleIndexInParent
in class AccessibleContext
AccessibleContext.getAccessibleParent()
,
AccessibleContext.getAccessibleChildrenCount()
,
AccessibleContext.getAccessibleChild(int)
public int getAccessibleChildrenCount()
getAccessibleChildrenCount
in class AccessibleContext
public Accessible getAccessibleChild(int i)
getAccessibleChild
in class AccessibleContext
i
- zero-based index of childAccessibleContext.getAccessibleChildrenCount()
public Locale getLocale() throws IllegalComponentStateException
Locale
of the component. If the component does not have a
locale, the locale of its parent is returned.getLocale
in class AccessibleContext
Locale
of the objectIllegalComponentStateException
- 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.public void addPropertyChangeListener(PropertyChangeListener l)
PropertyChangeListener
to the listener list. The listener
is registered for all properties.addPropertyChangeListener
in class AccessibleContext
l
- The PropertyChangeListener to be addedAccessibleContext.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
public void removePropertyChangeListener(PropertyChangeListener l)
PropertyChangeListener
from the listener list.removePropertyChangeListener
in class AccessibleContext
l
- The PropertyChangeListener to be removedpublic Color getBackground()
Color
of this object.getBackground
in interface AccessibleComponent
Color
of the object;
otherwise, nullAccessibleComponent.setBackground(java.awt.Color)
public void setBackground(Color c)
Color
of this object.setBackground
in interface AccessibleComponent
c
- the new Color
for the backgroundAccessibleComponent.setBackground(java.awt.Color)
public Color getForeground()
Color
of this object.getForeground
in interface AccessibleComponent
Color
of the object; otherwise, nullAccessibleComponent.setForeground(java.awt.Color)
public void setForeground(Color c)
Color
of this object.setForeground
in interface AccessibleComponent
c
- the new Color
for the foregroundAccessibleComponent.getForeground()
public Cursor getCursor()
Cursor
of this object.getCursor
in interface AccessibleComponent
AccessibleComponent.setCursor(java.awt.Cursor)
public void setCursor(Cursor c)
Cursor
of this object.setCursor
in interface AccessibleComponent
c
- the new Cursor
for the objectAccessibleComponent.getCursor()
public Font getFont()
Font
of this object.getFont
in interface AccessibleComponent
Font
for the object; otherwise, nullAccessibleComponent.setFont(java.awt.Font)
public void setFont(Font f)
Font
of this object.setFont
in interface AccessibleComponent
f
- the new Font
for the objectAccessibleComponent.getFont()
public FontMetrics getFontMetrics(Font f)
FontMetrics
of this object.getFontMetrics
in interface AccessibleComponent
f
- the Font
FontMetrics
the object; otherwise, nullgetFont()
public boolean isEnabled()
isEnabled
in interface AccessibleComponent
AccessibleComponent.setEnabled(boolean)
,
AccessibleContext.getAccessibleStateSet()
,
AccessibleState.ENABLED
,
AccessibleStateSet
public void setEnabled(boolean b)
setEnabled
in interface AccessibleComponent
b
- if true, enables this object; otherwise, disables itAccessibleComponent.isEnabled()
public boolean isVisible()
isVisible
in interface AccessibleComponent
AccessibleComponent.setVisible(boolean)
,
AccessibleContext.getAccessibleStateSet()
,
AccessibleState.VISIBLE
,
AccessibleStateSet
public void setVisible(boolean b)
setVisible
in interface AccessibleComponent
b
- if true, shows this object; otherwise, hides itAccessibleComponent.isVisible()
public boolean isShowing()
isShowing
in interface AccessibleComponent
public boolean contains(Point p)
Point
is within this
object's bounds, where the Point
is relative to the coordinate
system of the object.contains
in interface AccessibleComponent
p
- the Point
relative to the coordinate system of the objectPoint
; otherwise falseAccessibleComponent.getBounds()
public Point getLocationOnScreen()
getLocationOnScreen
in interface AccessibleComponent
AccessibleComponent.getBounds()
,
AccessibleComponent.getLocation()
public Point getLocation()
getLocation
in interface AccessibleComponent
AccessibleComponent.getBounds()
,
AccessibleComponent.getLocationOnScreen()
public void setLocation(Point p)
setLocation
in interface AccessibleComponent
p
- the new position for the top-left cornerAccessibleComponent.getLocation()
public Rectangle getBounds()
getBounds
in interface AccessibleComponent
AccessibleComponent.contains(java.awt.Point)
public void setBounds(Rectangle r)
setBounds
in interface AccessibleComponent
r
- rectangle indicating this component's boundsAccessibleComponent.getBounds()
public Dimension getSize()
getSize
in interface AccessibleComponent
AccessibleComponent.setSize(java.awt.Dimension)
public void setSize(Dimension d)
setSize
in interface AccessibleComponent
d
- The dimension specifying the new size of the object.AccessibleComponent.getSize()
public Accessible getAccessibleAt(Point p)
getAccessibleAt
in interface AccessibleComponent
p
- The point relative to the coordinate system of this object.public boolean isFocusTraversable()
isFocusTraversable
in interface AccessibleComponent
AccessibleContext.getAccessibleStateSet()
,
AccessibleState.FOCUSABLE
,
AccessibleState.FOCUSED
,
AccessibleStateSet
public void requestFocus()
requestFocus
in interface AccessibleComponent
AccessibleComponent.isFocusTraversable()
public void addFocusListener(FocusListener l)
FocusListener
to receive focus events from
this component.addFocusListener
in interface AccessibleComponent
l
- the focus listenerAccessibleComponent.removeFocusListener(java.awt.event.FocusListener)
public void removeFocusListener(FocusListener l)
removeFocusListener
in interface AccessibleComponent
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.AccessibleComponent.addFocusListener(java.awt.event.FocusListener)
Copyright © 2002, 2016, Oracle and/or its affiliates. All rights reserved.