2

我有一个 JEditorPane 设置为编辑 html 输入,我想更改换行行为,以便当我转到新行时,它会插入<\br>而不是将文本包围在<p></p>. 目前我有以下内容。

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);

当我newSignatureEditorPane.getText()在 saveChangesButtonAction 中执行操作时,这会导致以下结果:

<html>
<head>
</head>
<body>
<p style="margin-top: 0">
  Line 1
</p>
<p style="margin-top: 0">
  Line 2
</p>
</body>
</html>
4

0 回答 0