Example usage for javax.swing.text View getClass

List of usage examples for javax.swing.text View getClass

Introduction

In this page you can find the example usage for javax.swing.text View getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:TextFieldViews.java

public static void displayView(View view, int indent, Document doc, PrintStream out) {
    String name = view.getClass().getName();
    for (int i = 0; i < indent; i++) {
        out.print("\t");
    }//from   ww w  .  j  av a2  s  .  c  om

    int start = view.getStartOffset();
    int end = view.getEndOffset();
    out.println(name + "; offsets [" + start + ", " + end + "]");
    int viewCount = view.getViewCount();
    if (viewCount == 0) {
        int length = Math.min(32, end - start);
        try {
            String txt = doc.getText(start, length);
            for (int i = 0; i < indent + 1; i++) {
                out.print("\t");
            }
            out.println("[" + txt + "]");
        } catch (BadLocationException e) {
        }
    } else {
        for (int i = 0; i < viewCount; i++) {
            displayView(view.getView(i), indent + 1, doc, out);
        }
    }
}

From source file:ShowHTMLViews.java

public static void displayView(View view, int indent, Document doc, PrintStream out) {
    String name = view.getClass().getName();
    for (int i = 0; i < indent; i++) {
        out.print("  ");
    }/*w w  w  . ja v  a  2  s. co m*/

    int start = view.getStartOffset();
    int end = view.getEndOffset();
    out.println(name + "; offsets [" + start + ", " + end + "]");
    for (int i = 0; i < indent; i++) {
        out.print("  ");
    }
    HTMLDocDisplay.displayAttributes(view.getAttributes(), indent, out);
    int viewCount = view.getViewCount();
    if (viewCount == 0) {
        int length = Math.min(32, end - start);
        try {
            String txt = doc.getText(start, length);
            for (int i = 0; i < indent + 1; i++) {
                out.print("  ");
            }
            out.println("[" + txt + "]");
        } catch (BadLocationException e) {
        }
    } else {
        for (int i = 0; i < viewCount; i++) {
            displayView(view.getView(i), indent + 1, doc, out);
        }
    }
    out.println("");
}

From source file:TextComponentDisplay.java

public static void displayView(View view, int tabs, PrintStream out) {
    // Print info about this view
    for (int i = 0; i < tabs; i++) {
        out.print("\t");
    }//ww w  . j a va  2s.  c  o  m

    out.println(view.getClass().getName());

    for (int i = 0; i < tabs; i++) {
        out.print("\t");
    }

    out.println("Start: " + view.getStartOffset() + "; end: " + view.getEndOffset());

    // Display child views, if any.
    int childViews = view.getViewCount();
    for (int i = 0; i < childViews; i++) {
        View childView = view.getView(i);
        displayView(childView, tabs + 1, out);
    }
}