Originally posted by Derek Boring:
What doesn't work is that the JEditorPane shows the HTML tags rather than formatting the text between them. I've tried both typing in the tags myself and using something similar to txtDoc.setText("<B>This is bold.</B>"); or txtDoc.setText("<HTML><B>This is bold.</B></HTML>"); and it still just shows the tags. (even the <HTML></HTML> tags)
It sounds like you haven't set up the JEditorPane to use the HTMLEditorKit.
As mentioned in the linked
thread, the easiest way to do this is to instantiate it like this:
JEditorPane subjectPanel = new JEditorPane("text/html", ""); Replace "" with some HTML markup if you wish, or call setText(). It should interpret the HTML tags, not display them as text.