我想将制表符 \t 的大小设置JTextPane
为 4 个空格宽。
在谷歌搜索了很多之后,我发现了一些我将在此处包含的内容,以说明我尝试过的内容以及它们失败的原因。
JTextPane
不是普通文档。
Eclipse 引发了一些错误:
Type mismatch: cannot convert from javax.swing.text.AttributeSet to
javax.print.attribute.AttributeSet
和
The method setParagraphAttributes(javax.swing.text.AttributeSet, boolean) in the type JTextPane is not applicable for the
arguments (javax.print.attribute.AttributeSet, boolean)
http://www.java2s.com/Code/Java/Swing-JFC/TextPaneSample.htm
此页面讨论使用JTextPane
. 我从中改编的代码并做了这个:
MutableAttributeSet set = new SimpleAttributeSet(pane.getParagraphAttributes());
StyleConstants.setLeftIndent(set, 40);
StyleConstants.setRightIndent(set, 40);