I don't know exactly why. I know, however, it's related with text being appended after a </html>
tag. When you setText()
on a JEditorPane with text/html
content type, <html>
tags are automatically added.
I dealt with a similar problem before. The way I fixed it was saving all the text in a string, then setting it in the pane:
String s = "";
...
s += msg;
conversationPane.setText(s);