I have a JEditorPane set to edit html input and I would like to change the newline behavior so that when I go to a new line it inserts <\br>
instead of surrounding the text in <p></p>
. At the moment I have the following.
newSignatureScrollPane = new javax.swing.JScrollPane();
newSignatureEditorPane = new javax.swing.JEditorPane();
newSignatureEditorPane.setContentType("text/html"); // NOI18N
newSignatureEditorPane.setDocument(new HTMLDocument());
newSignatureEditorPane.setEditorKit(new HTMLEditorKit());
newSignatureScrollPane.setViewportView(newSignatureEditorPane);
This results in the following when I do a newSignatureEditorPane.getText()
in my saveChangesButtonAction:
<html>
<head>
</head>
<body>
<p style="margin-top: 0">
Line 1
</p>
<p style="margin-top: 0">
Line 2
</p>
</body>
</html>
or
https://stackoverflow.com/a/1946446/6358346 – Grant Foster Nov 19 '18 at 22:50
`. Google uses ``, so I guess that would be good too. – user3621877 Nov 19 '18 at 22:59