Search code examples
javaswingjeditorpane

Give JEditorPane an append(...) Method like JTextArea


How can I use jEditorPane as jTextArea with the append method in the jTextarea ?

example :

jTextArea.append(mystring);

jEditorPane.?


Solution

  • I would take a look at the Document, specifically, the Document#insertString method.

    With this you could could do something like...

    Document doc = editorPane.getDocument();
    doc.insertString(doc.getLength(), "This is the string to insert", null);