当我使用 JTextPane 并在 HTML 编辑器模式下键入一些文本时
JTextPane textPane = new JTextPane();
textPane.setContentType("text/html");
//...
textPane.setText(textPane.getText());
行首的空格被删除。为什么?
最佳答案
尝试使用
在 text/html 内容类型的开头添加空格。
此链接描述了如何在 html 中添加空格的方法:http://webdesign.about.com/od/beginningtutorials/qt/spaces-in-html.htm您可以使用其中之一。
关于java - JTextPane.setText(JTextPane.getText()) 清除 HTML 模式下的空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26453521/