Reputation: 43
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>
Upvotes: 2
Views: 116