I want to set the size of a tab character, \t, in a JTextPane
to be 4 spaces wide.
After Googling quite a bit I found some things that I will include here for what I have tried and maybe why they failed.
How do you set the tab size in a JEditorPane?
JTextPane
is not a plain document.
Eclipse raised some errors:
Type mismatch: cannot convert from javax.swing.text.AttributeSet to
javax.print.attribute.AttributeSet
and
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
This page talks about styling with JTextPane
. The code I adapted from it and made this:
MutableAttributeSet set = new SimpleAttributeSet(pane.getParagraphAttributes());
StyleConstants.setLeftIndent(set, 40);
StyleConstants.setRightIndent(set, 40);