gpt4 book ai didi

java - JTextPane.setText(JTextPane.getText()) 清除 HTML 模式下的空白

转载 作者:行者123 更新时间:2023-12-01 12:24:44 25 4
gpt4 key购买 nike

当我使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com