title: Java add global JTextPane styles/attributes?
body: <p>I want to add a global AttributeSet to my JTextPane.</p>
  
  <p>I found this:</p>
  
  <pre><code>SimpleAttributeSet style = new SimpleAttributeSet();
  StyleConstants.setLeftIndent(style, 20);
  StyleConstants.setFirstLineIndent(style, -20);
  </code></pre>
  
  <p>From <a href="http://java-sl.com/tip_hanging_first_line.html" rel="nofollow">http://java-sl.com/tip_hanging_first_line.html</a></p>
  
  <p>I'm wondering how I can set the "default stylesheet"? (not using HTML). I then tried this:</p>
  
  <pre><code>StyleContext style = new StyleContext();
  Style s = style.addStyle("test", null);
  StyleConstants.setForeground(s, Color.BLUE);
  StyledDocument d = (StyledDocument) console.getOutputField().getDocument();
  </code></pre>
  
  <p>From <a href="http://www.java2s.com/Code/Java/Swing-JFC/JTextPaneStylesExample1.htm" rel="nofollow">http://www.java2s.com/Code/Java/Swing-JFC/JTextPaneStylesExample1.htm</a> without luck.</p>
  
  <p>I know StyledDocument has specific properties for setting stuff like foreground colour - which is why this may not work - but can anyone point me as to how to use the other style attributes? Such as the left indent and first line indent.</p>