I have a jEditorPane that is HTML based.
i found out that you can use:
String text = jEditorPane1.getDocument().getText(0, jEditorPane1.getDocument().getLength());
text = text.replaceAll("(?<!^)\n", "\n<br />");
jEditorPane1.setText("<html>" + text + "</html>");
by this way i got the text out of the editorpane. and when i want to put it back in the editorpane, i just replace the newline symbols with a < br />. and than put it back.
until now it is all fine. but when i got the text for the second time out of the editorpane, there are no newline symbols.
how can i keep this newline symbols?
this did the job for me. thanks to stanislavl!
i have checked how normaly a newline works in a jeditpane in html mode. it is the p tag with no margin.
strange implimentation, however it worked.
this does the real job. it surrounds all text after a \n with the < p>< /p> tag.
thanks for helping