Example usage for javax.accessibility AccessibleContext getAccessibleText

List of usage examples for javax.accessibility AccessibleContext getAccessibleText

Introduction

In this page you can find the example usage for javax.accessibility AccessibleContext getAccessibleText.

Prototype

public AccessibleText getAccessibleText() 

Source Link

Document

Gets the AccessibleText associated with this object presenting text on the display.

Usage

From source file:MainClass.java

void dumpTextInfo(AccessibleContext ac) {
    AccessibleText at = ac.getAccessibleText();

    if (at != null) {
        System.out.println("Caret position = " + at.getCaretPosition());
        System.out.println("Selected text = " + at.getSelectedText());

        return;/*  w  w w.  java 2s.  co m*/
    }

    int nChildren = ac.getAccessibleChildrenCount();

    for (int i = 0; i < nChildren; i++)
        dumpTextInfo(ac.getAccessibleChild(i).getAccessibleContext());
}

From source file:MainClass.java

void dumpHypertextInfo(AccessibleContext ac) {
    AccessibleText at = ac.getAccessibleText();

    AccessibleHypertext ah = null;
    if (at instanceof AccessibleHypertext)
        ah = (AccessibleHypertext) at;

    if (ah != null) {
        int nLinks = ah.getLinkCount();

        for (int i = 0; i < nLinks; i++) {
            AccessibleHyperlink ahl = ah.getLink(i);

            int nActions = ahl.getAccessibleActionCount();

            for (int j = 0; j < nActions; j++) {
                String s = ahl.getAccessibleActionDescription(j);
                System.out.println("Action = " + s);
            }/*ww w .  jav  a2  s .co  m*/
        }
        return;
    }

    int nChildren = ac.getAccessibleChildrenCount();

    for (int i = 0; i < nChildren; i++)
        dumpHypertextInfo(ac.getAccessibleChild(i).getAccessibleContext());
}