所有类


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 intCHARACTER
          用于指示应被检索的文本部分是一个字符的常量。
static intSENTENCE
          用于指示应被检索的文本部分是一个语句的常量。
static intWORD
          用于指示应被检索的文本部分是一个单词的常量。
 
方法摘要
 StringgetAfterIndex(int part, int index)
          返回给定索引后的 String。
 StringgetAtIndex(int part, int index)
          返回给定索引处的 String。
 StringgetBeforeIndex(int part, int index)
          返回给定索引前面的 String。
 intgetCaretPosition()
          返回从零开始的插入符偏移量。
 AttributeSetgetCharacterAttribute(int i)
          返回给定索引处给定字符的 AttributeSet
 RectanglegetCharacterBounds(int i)
          确定字符串中给定索引处的字符的边界框。
 intgetCharCount()
          返回字符(有效索引)数
 intgetIndexAtPoint(Point p)
          给定本地坐标中的一点,返回在该 Point 下的字符从零开始的索引。
 StringgetSelectedText()
          返回选中的部分文本。
 intgetSelectionEnd()
          返回选定文本中的结束偏移量。
 intgetSelectionStart()
          返回选定文本中的起始偏移量。
 

字段详细信息

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
用于指示应被检索的文本部分是一个语句的常量。

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

getIndexAtPoint

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

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

getCharacterBounds

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

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

getCharCount

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

返回:
字符数

getCaretPosition

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

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

getAtIndex

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

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