I am currently using a JEditorPane to display text that is being read from a Socket. I create the JEditorPane, get its Document and add the text as it comes using
document.insertString(document.getEndPosition().getOffset(), string, null);
This works as expected, except that when It encounters a ‘\n’ (The character being used for a newline), it seems to ignore it (i.e. not print anything), and everything comes out on one line. I’ve looked around for a solution but I can’t seem to find anything that works (Tried replacing ‘\n’ with <br>, didn’t help, it just printed out the <br>.
It works as you expected.
Here is the code.
the complete code.
You can also use,