title: JTextPane and foreground color
body: <p>want to have a JTextPane whose content can always be selected by the user. Therefore I created my own subclass of JTextPane and always return true in the method "isEnabled()". Additionally I introduce a new member m_enabled which is responsible for returning the correct foreground color (enabled/disabled).</p>
  
  <p>It works as expected, but if I set a default foreground color (e.g. Color.RED) and toggle between enabled and disabled, the foreground color won't be red anymore.</p>
  
  <p>Can you help me to solve this issue?</p>
  
  <pre><code>public class StylesExample1 {
  public static final String text = "Lorem ipsum dolor...";
  public static boolean m_enabled = true;
  
  public static void main(String[] args) throws BadLocationException {
      try {
          UIManager
                  .setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
      } catch (Exception evt) {
      }
  
      JFrame f = new JFrame("Frame");
      final JTextPane pane = new MyPane();
      pane.setText(text);
  
      pane.setPreferredSize(new Dimension(200, 200));
      f.getContentPane().add(pane);
      JButton b = new JButton("Toggle Enabled state");
      b.addActionListener(new ActionListener() {
  
          @Override
          public void actionPerformed(ActionEvent e) {
              m_enabled = !m_enabled;
              System.err.println("setting textpane enabled to " + m_enabled);
              pane.setEnabled(m_enabled);
          }
      });
  
      pane.setForeground(Color.red);
  
      f.getContentPane().add(b);
      f.getContentPane().setLayout(new FlowLayout());
      f.setSize(400, 300);
      f.setVisible(true);
  }
  }
  
  class MyPane extends JTextPane {
  
  private static final long serialVersionUID = 1L;
  private boolean m_enabled = true;
  private Color defaultForegroundColor, disabledTextColor;
  
  public MyPane() {
      defaultForegroundColor = getForeground();
      disabledTextColor = getDisabledTextColor();
  }
  
  public void setEnabled(boolean enabled) {
      m_enabled = enabled;
  
      if (m_enabled) {
          setForeground(defaultForegroundColor);
      } else {
          setForeground(disabledTextColor);
      }
  }
  
  @Override
  public boolean isEnabled() {
      return true;
  }
  }
  </code></pre>