title: Java Setting Indent Size on JTextPane
body: <p>I want to set the size of a tab character, \t, in a <code>JTextPane</code> to be 4 spaces wide.</p>
  
  <p>After Googling quite a bit I found some things that I will include here for what I have tried and maybe why they failed.</p>
  
  <p><a href="https://stackoverflow.com/questions/757692/how-do-you-set-the-tab-size-in-a-jeditorpane">How do you set the tab size in a JEditorPane?</a></p>
  
  <p><code>JTextPane</code> is not a plain document.</p>
  
  <p><a href="https://stackoverflow.com/questions/22721955/java-jtextpane-tab-size">Java JTextpane Tab Size</a></p>
  
  <p>Eclipse raised some errors: </p>
  
  <pre><code>Type mismatch: cannot convert from javax.swing.text.AttributeSet to 
   javax.print.attribute.AttributeSet
  </code></pre>
  
  <p>and</p>
  
  <pre><code>The method setParagraphAttributes(javax.swing.text.AttributeSet, boolean) in the type JTextPane is not applicable for the 
   arguments (javax.print.attribute.AttributeSet, boolean)
  </code></pre>
  
  <p><a href="http://www.java2s.com/Code/Java/Swing-JFC/TextPaneSample.htm" rel="nofollow noreferrer">http://www.java2s.com/Code/Java/Swing-JFC/TextPaneSample.htm</a></p>
  
  <p>This page talks about styling with <code>JTextPane</code>. The code I adapted from it and made this:</p>
  
  <pre><code>MutableAttributeSet set = new SimpleAttributeSet(pane.getParagraphAttributes());
  StyleConstants.setLeftIndent(set, 40);
  StyleConstants.setRightIndent(set, 40);
  </code></pre>