Search in sources :

Example 61 with Document

use of javax.swing.text.Document in project jdk8u_jdk by JetBrains.

the class ElementTreePanel method setEditor.

/**
     * Resets the JTextComponent to <code>editor</code>. This will update
     * the tree accordingly.
     */
public void setEditor(JTextComponent editor) {
    if (this.editor == editor) {
        return;
    }
    if (this.editor != null) {
        Document oldDoc = this.editor.getDocument();
        oldDoc.removeDocumentListener(this);
        this.editor.removePropertyChangeListener(this);
        this.editor.removeCaretListener(this);
    }
    this.editor = editor;
    if (editor == null) {
        treeModel = null;
        tree.setModel(null);
    } else {
        Document newDoc = editor.getDocument();
        newDoc.addDocumentListener(this);
        editor.addPropertyChangeListener(this);
        editor.addCaretListener(this);
        treeModel = new ElementTreeModel(newDoc);
        tree.setModel(treeModel);
    }
}
Also used : Document(javax.swing.text.Document)

Example 62 with Document

use of javax.swing.text.Document in project beast-mcmc by beast-dev.

the class TextUtil method createHTMLScrollPane.

public static JScrollPane createHTMLScrollPane(String text, Dimension dimension) {
    JEditorPane jEditorPane = new JEditorPane();
    jEditorPane.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(jEditorPane);
    HTMLEditorKit kit = new HTMLEditorKit();
    jEditorPane.setEditorKit(kit);
    // create a document, set it on the jeditorpane, then add the html
    Document doc = kit.createDefaultDocument();
    jEditorPane.setDocument(doc);
    jEditorPane.setText(text);
    // to make html auto wrap
    jEditorPane.setPreferredSize(dimension);
    return scrollPane;
}
Also used : HTMLEditorKit(javax.swing.text.html.HTMLEditorKit) Document(javax.swing.text.Document)

Example 63 with Document

use of javax.swing.text.Document in project beast-mcmc by beast-dev.

the class RealNumberField method createDefaultModel.

protected Document createDefaultModel() {
    Document doc = new RealNumberField.RealNumberFieldDocument();
    doc.addDocumentListener(this);
    return doc;
}
Also used : Document(javax.swing.text.Document) PlainDocument(javax.swing.text.PlainDocument)

Example 64 with Document

use of javax.swing.text.Document in project beast-mcmc by beast-dev.

the class WholeNumberField method createDefaultModel.

protected Document createDefaultModel() {
    Document doc = new WholeNumberFieldDocument();
    doc.addDocumentListener(this);
    return doc;
}
Also used : Document(javax.swing.text.Document) PlainDocument(javax.swing.text.PlainDocument)

Aggregations

Document (javax.swing.text.Document)64 BadLocationException (javax.swing.text.BadLocationException)29 DocumentEvent (javax.swing.event.DocumentEvent)10 DefaultStyledDocument (javax.swing.text.DefaultStyledDocument)8 DocumentAdapter (com.intellij.ui.DocumentAdapter)7 HTMLDocument (javax.swing.text.html.HTMLDocument)7 ActionEvent (java.awt.event.ActionEvent)5 PlainDocument (javax.swing.text.PlainDocument)5 ActionListener (java.awt.event.ActionListener)4 File (java.io.File)3 IOException (java.io.IOException)3 DocumentListener (javax.swing.event.DocumentListener)3 Element (javax.swing.text.Element)3 FieldPanel (com.intellij.ui.FieldPanel)2 CheckBox (com.intellij.util.ui.CheckBox)2 NumberFormat (java.text.NumberFormat)2 ParseException (java.text.ParseException)2 AbstractAction (javax.swing.AbstractAction)2 AbstractDocument (javax.swing.text.AbstractDocument)2 SimpleAttributeSet (javax.swing.text.SimpleAttributeSet)2