我想在中追加html内容,但是当我以这种方式追加时,它会在现有文本的末尾自动JEditorPane
插入换行符,如何避免这种情况。
JEditorPane pn = new JEditorPane();
pn.setContentType("text/html");
pn.setText("This is line 1");
...
//after some time
HTMLDocument doc = (HTMLDocument) pn.getDocument();
HTMLEditorKit kit = (HTMLEditorKit) pn.getEditorKit();
kit.insertHTML(doc, doc.getLength(), "<b>Hello</b>", 0, 0, null);
kit.insertHTML(doc, doc.getLength(), "World", 0, 0, null);
insertHTML()
每次调用它都会在现有文本的末尾放置一个换行符。这是默认行为吗?如果是这样,我该如何处理?