模块 java.desktop

界面无障碍文本

所有已知的子接口:
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 )然后调用AccessibleContextAccessibleContext.getAccessibleText() 方法来确定对象是否支持AccessibleText接口。如果返回值不是 null ,则该对象支持此接口。
参见:
  • 字段摘要

    字段
    修饰符和类型
    Field
    描述
    static final int
    用于指示应检索的文本部分是字符的常量。
    static final int
    常量,用于指示应该检索的文本部分是一个句子。
    static final int
    用于指示应检索的文本部分是单词的常量。
  • 方法总结

    修饰符和类型
    方法
    描述
    getAfterIndex(int part, int index)
    返回给定索引后的 String
    getAtIndex(int part, int index)
    返回给定索引处的 String
    getBeforeIndex(int part, int index)
    返回给定索引之前的 String
    int
    返回插入符号从零开始的偏移量。
    返回给定索引处给定字符的 AttributeSet
    确定字符串中给定索引处字符的边界框。
    int
    返回字符数(有效索引)。
    int
    给定局部坐标中的一个点,返回该点下字符的从零开始的索引。
    返回选定的文本部分。
    int
    返回所选文本中的结束偏移量。
    int
    返回所选文本中的起始偏移量。
  • 字段详细信息

  • 方法详情

    • getIndexAtPoint

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

      Rectangle  getCharacterBounds(int i)
      确定字符串中给定索引处字符的边界框。边界以局部坐标返回。如果索引无效,则返回一个空矩形。
      参数:
      i - 字符串的索引
      返回:
      字符边界框的屏幕坐标,如果索引无效,则返回一个空矩形。
    • getCharCount

      int getCharCount()
      返回字符数(有效索引)。
      返回:
      字符数
    • getCaretPosition

      int getCaretPosition()
      返回插入符号从零开始的偏移量。

      注意:插入符号右侧的索引值与偏移量相同(插入符号位于两个字符之间)。

      返回:
      插入符号从零开始的偏移量
    • getAtIndex

      String  getAtIndex(int part, int index)
      返回给定索引处的 String
      参数:
      part - 要检索的字符、单词或句子
      index - 文本中的索引
      返回:
      字母、单词或句子
    • getAfterIndex

      String  getAfterIndex(int part, int index)
      返回给定索引后的 String
      参数:
      part - 要检索的字符、单词或句子
      index - 文本中的索引
      返回:
      字母、单词或句子
    • getBeforeIndex

      String  getBeforeIndex(int part, int index)
      返回给定索引之前的 String
      参数:
      part - 要检索的字符、单词或句子
      index - 文本中的索引
      返回:
      字母、单词或句子
    • getCharacterAttribute

      AttributeSet  getCharacterAttribute(int i)
      返回给定索引处给定字符的 AttributeSet
      参数:
      i - 从零开始的文本索引
      返回:
      角色的AttributeSet
    • getSelectionStart

      int getSelectionStart()
      返回所选文本中的起始偏移量。如果没有选择,但有插入符号,则开始和结束偏移量将相同。
      返回:
      选择开始的文本中的索引
    • getSelectionEnd

      int getSelectionEnd()
      返回所选文本中的结束偏移量。如果没有选择,但有插入符号,则开始和结束偏移量将相同。
      返回:
      索引到选择结束的文本
    • getSelectedText

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