Can't remove extra line spacing in JTextPane for html content

做~自己de王妃 提交于 2019-12-02 03:22:20
trashgod

This may be platform dependent:

Try something like this

StyledDocument doc= textPane.getStyledDocument();
MutableAttributeSet attr= new SimpleAttributeSet();
StyleConstants.setLineSpacing(attr, -0.2f); //NOTE: negative value.

Looks like you are running windows. What version of JDK/JRE is in use?

Solved! If I use Courier New instead of monospace for the font-family, the line spacing is exactly the same as in the text-plain version under Windows. Thanks everyone!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!