class. It provides an implementation of the
Java Accessibility API appropriate to text component user-interface
elements.
| Method from java.awt.TextComponent$AccessibleAWTTextComponent Detail: |
public AccessibleRole getAccessibleRole() {
return AccessibleRole.TEXT;
}
Gets the role of this object. |
public AccessibleStateSet getAccessibleStateSet() {
AccessibleStateSet states = super.getAccessibleStateSet();
if (TextComponent.this.isEditable()) {
states.add(AccessibleState.EDITABLE);
}
return states;
}
Gets the state set of the TextComponent.
The AccessibleStateSet of an object is composed of a set of
unique AccessibleStates. A change in the AccessibleStateSet
of an object will cause a PropertyChangeEvent to be fired
for the AccessibleContext.ACCESSIBLE_STATE_PROPERTY property. |
public AccessibleText getAccessibleText() {
return this;
}
Get the AccessibleText associated with this object. In the
implementation of the Java Accessibility API for this class,
return this object, which is responsible for implementing the
AccessibleText interface on behalf of itself. |
public String getAfterIndex(int part,
int index) {
if (index < 0 || index >= TextComponent.this.getText().length()) {
return null;
}
switch (part) {
case AccessibleText.CHARACTER:
if (index+1 >= TextComponent.this.getText().length()) {
return null;
}
return TextComponent.this.getText().substring(index+1, index+2);
case AccessibleText.WORD: {
String s = TextComponent.this.getText();
BreakIterator words = BreakIterator.getWordInstance();
words.setText(s);
int start = findWordLimit(index, words, NEXT, s);
if (start == BreakIterator.DONE || start >= s.length()) {
return null;
}
int end = words.following(start);
if (end == BreakIterator.DONE || end >= s.length()) {
return null;
}
return s.substring(start, end);
}
case AccessibleText.SENTENCE: {
String s = TextComponent.this.getText();
BreakIterator sentence = BreakIterator.getSentenceInstance();
sentence.setText(s);
int start = sentence.following(index);
if (start == BreakIterator.DONE || start >= s.length()) {
return null;
}
int end = sentence.following(start);
if (end == BreakIterator.DONE || end >= s.length()) {
return null;
}
return s.substring(start, end);
}
default:
return null;
}
}
Returns the String after a given index. |
public String getAtIndex(int part,
int index) {
if (index < 0 || index >= TextComponent.this.getText().length()) {
return null;
}
switch (part) {
case AccessibleText.CHARACTER:
return TextComponent.this.getText().substring(index, index+1);
case AccessibleText.WORD: {
String s = TextComponent.this.getText();
BreakIterator words = BreakIterator.getWordInstance();
words.setText(s);
int end = words.following(index);
return s.substring(words.previous(), end);
}
case AccessibleText.SENTENCE: {
String s = TextComponent.this.getText();
BreakIterator sentence = BreakIterator.getSentenceInstance();
sentence.setText(s);
int end = sentence.following(index);
return s.substring(sentence.previous(), end);
}
default:
return null;
}
}
Returns the String at a given index. |
public String getBeforeIndex(int part,
int index) {
if (index < 0 || index > TextComponent.this.getText().length()-1) {
return null;
}
switch (part) {
case AccessibleText.CHARACTER:
if (index == 0) {
return null;
}
return TextComponent.this.getText().substring(index-1, index);
case AccessibleText.WORD: {
String s = TextComponent.this.getText();
BreakIterator words = BreakIterator.getWordInstance();
words.setText(s);
int end = findWordLimit(index, words, PREVIOUS, s);
if (end == BreakIterator.DONE) {
return null;
}
int start = words.preceding(end);
if (start == BreakIterator.DONE) {
return null;
}
return s.substring(start, end);
}
case AccessibleText.SENTENCE: {
String s = TextComponent.this.getText();
BreakIterator sentence = BreakIterator.getSentenceInstance();
sentence.setText(s);
int end = sentence.following(index);
end = sentence.previous();
int start = sentence.previous();
if (start == BreakIterator.DONE) {
return null;
}
return s.substring(start, end);
}
default:
return null;
}
}
Returns the String before a given index. |
public int getCaretPosition() {
return TextComponent.this.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). |
public int getCharCount() {
return TextComponent.this.getText().length();
}
Returns the number of characters (valid indicies) |
public AttributeSet getCharacterAttribute(int i) {
return null; // No attributes in TextComponent
}
Returns the AttributeSet for a given character (at a given index). |
public Rectangle getCharacterBounds(int i) {
return TextComponent.this.getCharacterBounds(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. |
public int getIndexAtPoint(Point p) {
return TextComponent.this.getIndexAtPoint(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. |
public String getSelectedText() {
String selText = TextComponent.this.getSelectedText();
// Fix for 4256662
if (selText == null || selText.equals("")) {
return null;
}
return selText;
}
Returns the portion of the text that is selected. |
public int getSelectionEnd() {
return TextComponent.this.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. |
public int getSelectionStart() {
return TextComponent.this.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. |
public void textValueChanged(TextEvent textEvent) {
Integer cpos = Integer.valueOf(TextComponent.this.getCaretPosition());
firePropertyChange(ACCESSIBLE_TEXT_PROPERTY, null, cpos);
}
TextListener notification of a text value change. |