Example usage for javax.swing.text.html HTMLDocument setTokenThreshold

List of usage examples for javax.swing.text.html HTMLDocument setTokenThreshold

Introduction

In this page you can find the example usage for javax.swing.text.html HTMLDocument setTokenThreshold.

Prototype

public void setTokenThreshold(int n) 

Source Link

Document

Sets the number of tokens to buffer before trying to update the documents element structure.

Usage

From source file:ReplaceReader.java

public static void main(String[] args) {
    try {/*  www.j  a v  a2s. c o  m*/
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception evt) {
    }

    JFrame f = new JFrame("JEditorPane with Custom Reader");
    JEditorPane ep = new JEditorPane();
    f.getContentPane().add(new JScrollPane(ep));
    f.setSize(400, 300);
    f.setVisible(true);

    HTMLEditorKit kit = new HTMLEditorKit() {
        public Document createDefaultDocument() {
            HTMLDocument doc = new CustomHTMLDocument(getStyleSheet());
            doc.setAsynchronousLoadPriority(4);
            doc.setTokenThreshold(100);
            return doc;
        }
    };
    ep.setEditorKit(kit);

    try {
        Document doc = ep.getDocument();
        doc.putProperty("IgnoreCharsetDirective", new Boolean(true));
        kit.read(new FileReader(args[0]), doc, 0);
    } catch (Exception e) {
        System.out.println("Exception while reading HTML " + e);
    }
}