JavaTM 2 Platform
Standard Ed. 6

javax.accessibility
接口 AccessibleText

所有已知子接口:
AccessibleEditableText, AccessibleHypertext
所有已知实现类:
AbstractButton.AccessibleAbstractButton, JButton.AccessibleJButton, JCheckBox.AccessibleJCheckBox, JCheckBoxMenuItem.AccessibleJCheckBoxMenuItem, JEditorPane.AccessibleJEditorPane, JEditorPane.AccessibleJEditorPaneHTML, JEditorPane.JEditorPaneAccessibleHypertextSupport, JLabel.AccessibleJLabel, JMenu.AccessibleJMenu, JMenuItem.AccessibleJMenuItem, JPasswordField.AccessibleJPasswordField, JRadioButton.AccessibleJRadioButton, JRadioButtonMenuItem.AccessibleJRadioButtonMenuItem, JSpinner.AccessibleJSpinner, JTextArea.AccessibleJTextArea, JTextComponent.AccessibleJTextComponent, JTextField.AccessibleJTextField, JToggleButton.AccessibleJToggleButton, ProgressMonitor.AccessibleProgressMonitor, TextArea.AccessibleAWTTextArea, TextComponent.AccessibleAWTTextComponent, TextField.AccessibleAWTTextField

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()
          返回选定文本中的起始偏移量。
 

字段详细信息

CHARACTER

static final int CHARACTER
用于指示应获取的文本部分是一个字符的常量。

另请参见:
getAtIndex(int, int), getAfterIndex(int, int), getBeforeIndex(int, int), 常量字段值

WORD

static final int WORD
用于指示应获取的文本部分是一个单词的常量。

另请参见:
getAtIndex(int, int), getAfterIndex(int, int), getBeforeIndex(int, int), 常量字段值

SENTENCE

static final int SENTENCE
用于指示应获取的文本部分是一个语句的常量。 句子是表示陈述、疑问、命令、希望、感叹或执行动作的单词字符串。在 English 语言环境下,该字符串通常以大写字母开始,以适当结束标点符号(如句号、问号或感叹号)结束。其他语言环境使用不同的大写和/或标点符号。

另请参见:
getAtIndex(int, int), getAfterIndex(int, int), getBeforeIndex(int, int), 常量字段值
方法详细信息

getIndexAtPoint

int getIndexAtPoint(Point p)
给定本地坐标中的一点,返回在该点下的字符从 0 开始的索引。如果该点无效,则此方法返回 -1。

参数:
p - 本地坐标中的点
返回:
点 p 处字符从 0 开始的索引;如果该点无效,则返回 -1。

getCharacterBounds

Rectangle getCharacterBounds(int i)
确定字符串中给定索引处的字符的边界框。以本地坐标形式返回边界。如果索引无效,则返回一个空的矩形。

参数:
i - String 中的索引
返回:
字符边界框的屏幕坐标;如果索引无效,则返回一个空矩形。

getCharCount

int getCharCount()
返回字符(有效索引)数

返回:
字符数

getCaretPosition

int getCaretPosition()
返回插入符从 0 开始的偏移量。 注:这表示插入符的右边与偏移量有相同的索引值(插入符在两个字符之间)。

返回:
插入符从 0 开始的偏移量。

getAtIndex

String getAtIndex(int part,
                  int index)
返回给定索引处的 String。

参数:
part - 要获取的 CHARACTER、WORD 或 SENTENCE
index - 文本中的索引
返回:
字母、单词或句子

getAfterIndex

String getAfterIndex(int part,
                     int index)
返回给定索引后面的 String。

参数:
part - 要获取的 CHARACTER、WORD 或 SENTENCE
index - 文本中的索引
返回:
字母、单词或句子

getBeforeIndex

String getBeforeIndex(int part,
                      int index)
返回给定索引前面的 String。

参数:
part - 要获取的 CHARACTER、WORD 或 SENTENCE
index - 文本中的索引
返回:
字母、单词或句子

getCharacterAttribute

AttributeSet getCharacterAttribute(int i)
返回给定索引处给定字符的 AttributeSet

参数:
i - 文本中从 0 开始的索引
返回:
字符的 AttributeSet

getSelectionStart

int getSelectionStart()
返回选定文本中的起始偏移量。如果没有选定的文本,但有一个插入符,则起始偏移量和结束偏移量将是相同的。

返回:
选定文本起始处的索引

getSelectionEnd

int getSelectionEnd()
返回选定文本中的结束偏移量。如果没有选定的文本,但有一个插入符,则起始偏移量和结束偏移量将是相同的。

返回:
选定文本结尾处的索引

getSelectedText

String getSelectedText()
返回选定的部分文本。

返回:
选定文本的 String 部分

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only