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);
}
}
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;
}
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;
}
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;
}
Aggregations