Java Platform 1.2

javax.swing.text
Class JTextComponent.AccessibleJTextComponent

java.lang.Object
  |
  +--javax.accessibility.AccessibleContext
        |
        +--javax.swing.JComponent.AccessibleJComponent
              |
              +--javax.swing.text.JTextComponent.AccessibleJTextComponent
Direct Known Subclasses:
JEditorPane.AccessibleJEditorPane, JTextArea.AccessibleJTextArea, JTextField.AccessibleJTextField

public class JTextComponent.AccessibleJTextComponent
extends JComponent.AccessibleJComponent
implements AccessibleText, CaretListener, DocumentListener

Accessibility implementation for JTextComponent.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JComponent.AccessibleJComponent
JComponent.AccessibleJComponent.AccessibleContainerHandler
 
Fields inherited from class javax.swing.JComponent.AccessibleJComponent
accessibleContainerHandler
 
Fields inherited from class javax.accessibility.AccessibleContext
ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY, ACCESSIBLE_CARET_PROPERTY, ACCESSIBLE_CHILD_PROPERTY, ACCESSIBLE_DESCRIPTION_PROPERTY, ACCESSIBLE_NAME_PROPERTY, ACCESSIBLE_SELECTION_PROPERTY, ACCESSIBLE_STATE_PROPERTY, ACCESSIBLE_TEXT_PROPERTY, ACCESSIBLE_VALUE_PROPERTY, ACCESSIBLE_VISIBLE_DATA_PROPERTY, accessibleDescription, accessibleName, accessibleParent
 
Constructor Summary
JTextComponent.AccessibleJTextComponent()
          Constructs an AccessibleJTextComponent.
 
Method Summary
 void caretUpdate(CaretEvent e)
          Handles caret updates (fire appropriate property change event, which are AccessibleContext.ACCESSIBLE_CARET_PROPERTY and AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY).
 void changedUpdate(DocumentEvent e)
          Handles document remove (fire appropriate property change event, which is AccessibleContext.ACCESSIBLE_TEXT_PROPERTY).
 AccessibleRole getAccessibleRole()
          Gets the role of this object.
 AccessibleStateSet getAccessibleStateSet()
          Gets the state set of the JTextComponent.
 AccessibleText getAccessibleText()
          Gets the AccessibleText interface associated with this object.
 String getAfterIndex(int part, int index)
          Returns the String after a given index.
 String getAtIndex(int part, int index)
          Returns the String at a given index.
 String getBeforeIndex(int part, int index)
          Returns the String before a given index.
 int getCaretPosition()
          Returns the zero-based offset of the caret.
 AttributeSet getCharacterAttribute(int i)
          Returns the AttributeSet for a given character (at a given index).
 Rectangle getCharacterBounds(int i)
          Determines the bounding box of the character at the given index into the string.
 int getCharCount()
          Returns the number of characters (valid indicies)
 int getIndexAtPoint(Point p)
          Given a point in local coordinates, return the zero-based index of the character under that Point.
 String getSelectedText()
          Returns the portion of the text that is selected.
 int getSelectionEnd()
          Returns the end offset within the selected text.
 int getSelectionStart()
          Returns the start offset within the selected text.
 void insertUpdate(DocumentEvent e)
          Handles document insert (fire appropriate property change event which is AccessibleContext.ACCESSIBLE_TEXT_PROPERTY).
 void removeUpdate(DocumentEvent e)
          Handles document remove (fire appropriate property change event, which is AccessibleContext.ACCESSIBLE_TEXT_PROPERTY).
 
Methods inherited from class javax.swing.JComponent.AccessibleJComponent
addFocusListener, addPropertyChangeListener, contains, getAccessibleAt, getAccessibleChild, getAccessibleChildrenCount, getAccessibleComponent, getAccessibleDescription, getAccessibleIndexInParent, getAccessibleName, getAccessibleParent, getBackground, getBorderTitle, getBounds, getCursor, getFont, getFontMetrics, getForeground, getLocale, getLocation, getLocationOnScreen, getSize, isEnabled, isFocusTraversable, isShowing, isVisible, removeFocusListener, removePropertyChangeListener, requestFocus, setBackground, setBounds, setCursor, setEnabled, setFont, setForeground, setLocation, setSize, setVisible
 
Methods inherited from class javax.accessibility.AccessibleContext
firePropertyChange, getAccessibleAction, getAccessibleSelection, getAccessibleValue, setAccessibleDescription, setAccessibleName, setAccessibleParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JTextComponent.AccessibleJTextComponent

public JTextComponent.AccessibleJTextComponent()
Constructs an AccessibleJTextComponent. Adds a listener to track caret change.
Method Detail

caretUpdate

public void caretUpdate(CaretEvent e)
Handles caret updates (fire appropriate property change event, which are AccessibleContext.ACCESSIBLE_CARET_PROPERTY and AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY). This keeps track of the dot position internally. When the caret moves, the internal position is updated after firing the event.
Specified by:
caretUpdate in interface CaretListener
Parameters:
e - the CaretEvent

insertUpdate

public void insertUpdate(DocumentEvent e)
Handles document insert (fire appropriate property change event which is AccessibleContext.ACCESSIBLE_TEXT_PROPERTY). This tracks the dot via the event.
Specified by:
insertUpdate in interface DocumentListener
Parameters:
e - the DocumentEvent

removeUpdate

public void removeUpdate(DocumentEvent e)
Handles document remove (fire appropriate property change event, which is AccessibleContext.ACCESSIBLE_TEXT_PROPERTY). This tracks the dot via the event.
Specified by:
removeUpdate in interface DocumentListener
Parameters:
e - the DocumentEvent

changedUpdate

public void changedUpdate(DocumentEvent e)
Handles document remove (fire appropriate property change event, which is AccessibleContext.ACCESSIBLE_TEXT_PROPERTY). This tracks the dot via the event.
Specified by:
changedUpdate in interface DocumentListener
Parameters:
e - the DocumentEvent

getAccessibleStateSet

public AccessibleStateSet getAccessibleStateSet()
Gets the state set of the JTextComponent. The AccessibleStateSet of an object is composed of a set of unique AccessibleState's. A change in the AccessibleStateSet of an object will cause a PropertyChangeEvent to be fired for the AccessibleContext.ACCESSIBLE_STATE_PROPERTY property.
Returns:
an instance of AccessibleStateSet containing the current state set of the object
Overrides:
getAccessibleStateSet in class JComponent.AccessibleJComponent
See Also:
AccessibleStateSet, AccessibleState, JComponent.addPropertyChangeListener(java.beans.PropertyChangeListener)

getAccessibleRole

public AccessibleRole getAccessibleRole()
Gets the role of this object.
Returns:
an instance of AccessibleRole describing the role of the object (AccessibleRole.TEXT)
Overrides:
getAccessibleRole in class JComponent.AccessibleJComponent
See Also:
AccessibleRole

getAccessibleText

public AccessibleText getAccessibleText()
Gets the AccessibleText interface associated with this object.
Returns:
an instance of AccessibleText
Overrides:
getAccessibleText in class AccessibleContext

getIndexAtPoint

public int getIndexAtPoint(Point p)
Given a point in local coordinates, return the zero-based index of the character under that Point. If the point is invalid, this method returns -1.
Specified by:
getIndexAtPoint in interface AccessibleText
Parameters:
p - the Point in local coordinates
Returns:
the zero-based index of the character under Point p.

getCharacterBounds

public Rectangle getCharacterBounds(int i)
Determines the bounding box of the character at the given index into the string. The bounds are returned in local coordinates. If the index is invalid a null rectangle is returned.
Specified by:
getCharacterBounds in interface AccessibleText
Parameters:
i - the index into the String >= 0
Returns:
the screen coordinates of the character's bounding box

getCharCount

public int getCharCount()
Returns the number of characters (valid indicies)
Specified by:
getCharCount in interface AccessibleText
Returns:
the number of characters >= 0

getCaretPosition

public int getCaretPosition()
Returns the zero-based offset of the caret. Note: The character to the right of the caret will have the same index value as the offset (the caret is between two characters).
Specified by:
getCaretPosition in interface AccessibleText
Returns:
the zero-based offset of the caret.

getCharacterAttribute

public AttributeSet getCharacterAttribute(int i)
Returns the AttributeSet for a given character (at a given index).
Specified by:
getCharacterAttribute in interface AccessibleText
Parameters:
i - the zero-based index into the text
Returns:
the AttributeSet of the character

getSelectionStart

public int getSelectionStart()
Returns the start offset within the selected text. If there is no selection, but there is a caret, the start and end offsets will be the same. Return 0 if the text is empty, or the caret position if no selection.
Specified by:
getSelectionStart in interface AccessibleText
Returns:
the index into the text of the start of the selection >= 0

getSelectionEnd

public int getSelectionEnd()
Returns the end offset within the selected text. If there is no selection, but there is a caret, the start and end offsets will be the same. Return 0 if the text is empty, or the caret position if no selection.
Specified by:
getSelectionEnd in interface AccessibleText
Returns:
the index into teh text of the end of the selection >= 0

getSelectedText

public String getSelectedText()
Returns the portion of the text that is selected.
Specified by:
getSelectedText in interface AccessibleText
Returns:
the text, null if no selection

getAtIndex

public String getAtIndex(int part,
                         int index)
Returns the String at a given index.
Specified by:
getAtIndex in interface AccessibleText
Parameters:
part - the AccessibleText.CHARACTER, AccessibleText.WORD, or AccessibleText.SENTENCE to retrieve
index - an index within the text >= 0
Returns:
the letter, word, or sentence, null for an invalid index or part

getAfterIndex

public String getAfterIndex(int part,
                            int index)
Returns the String after a given index.
Specified by:
getAfterIndex in interface AccessibleText
Parameters:
part - the AccessibleText.CHARACTER, AccessibleText.WORD, or AccessibleText.SENTENCE to retrieve
index - an index within the text >= 0
Returns:
the letter, word, or sentence, null for an invalid index or part

getBeforeIndex

public String getBeforeIndex(int part,
                             int index)
Returns the String before a given index.
Specified by:
getBeforeIndex in interface AccessibleText
Parameters:
part - the AccessibleText.CHARACTER, AccessibleText.WORD, or AccessibleText.SENTENCE to retrieve
index - an index within the text >= 0
Returns:
the letter, word, or sentence, null for an invalid index or part

Java Platform 1.2

Submit a bug or feature Version 1.2 of Java Platform API Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.