Example usage for javax.accessibility AccessibleText getCaretPosition

List of usage examples for javax.accessibility AccessibleText getCaretPosition

Introduction

In this page you can find the example usage for javax.accessibility AccessibleText getCaretPosition.

Prototype

public int getCaretPosition();

Source Link

Document

Returns the zero-based offset of the caret.

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. ja  v  a 2 s.  c  om*/
    }

    int nChildren = ac.getAccessibleChildrenCount();

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