如何设置htmleditorkit的换行行为

时间:2018-11-19 22:41:01

标签: java swing jeditorpane htmleditorkit

我设置了一个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);

当我在saveChangesButtonAction中执行newSignatureEditorPane.getText()时,结果如下:

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

0 个答案:

没有答案
相关问题