public interface AccessibleText
所有在显示器上显示文本信息的类都应该实现 AccessibleText 接口。此接口为辅助技术提供了标准机制,以通过文本的内容、属性和空间位置来访问该文本。应用程序通过先获取某个对象的 AccessibleContext(参见 Accessible),然后调用 AccessibleContext 的 AccessibleContext.getAccessibleText() 方法,能够确定该对象是否支持 AccessibleText 接口。如果返回值不为 null,则该对象支持此接口。
Accessible,
Accessible.getAccessibleContext(),
AccessibleContext,
AccessibleContext.getAccessibleText()
| 字段摘要 | |
|---|---|
static int |
CHARACTER 用于指示应获取的文本部分是一个字符的常量。 |
static int |
SENTENCE 用于指示应获取的文本部分是一个语句的常量。 |
static int |
WORD 用于指示应获取的文本部分是一个单词的常量。 |
| 方法摘要 | |
|---|---|
String |
getAfterIndex(int part, int index) 返回给定索引后面的 String。 |
String |
getAtIndex(int part, int index) 返回给定索引处的 String。 |
String |
getBeforeIndex(int part, int index) 返回给定索引前面的 String。 |
int |
getCaretPosition() 返回插入符从 0 开始的偏移量。 |
AttributeSet |
getCharacterAttribute(int i) 返回给定索引处给定字符的 AttributeSet |
Rectangle |
getCharacterBounds(int i) 确定字符串中给定索引处的字符的边界框。 |
int |
getCharCount() 返回字符(有效索引)数 |
int |
getIndexAtPoint(Point p) 给定本地坐标中的一点,返回在该点下的字符从 0 开始的索引。 |
String |
getSelectedText() 返回选定的部分文本。 |
int |
getSelectionEnd() 返回选定文本中的结束偏移量。 |
int |
getSelectionStart() 返回选定文本中的起始偏移量。 |
| 字段详细信息 |
|---|
static final int CHARACTER
static final int WORD
static final int SENTENCE
| 方法详细信息 |
|---|
int getIndexAtPoint(Point p)
p - 本地坐标中的点
Rectangle getCharacterBounds(int i)
i - String 中的索引
int getCharCount()
int getCaretPosition()
String getAtIndex(int part, int index)
part - 要获取的 CHARACTER、WORD 或 SENTENCE
index - 文本中的索引
String getAfterIndex(int part, int index)
part - 要获取的 CHARACTER、WORD 或 SENTENCE
index - 文本中的索引
String getBeforeIndex(int part, int index)
part - 要获取的 CHARACTER、WORD 或 SENTENCE
index - 文本中的索引
AttributeSet getCharacterAttribute(int i)
i - 文本中从 0 开始的索引
int getSelectionStart()
int getSelectionEnd()
String getSelectedText()