Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6789980

JEditorPane background color not honored with Nimbus L&F

XMLWordPrintable

    • b11
    • sparc
    • solaris_10

      FULL PRODUCT VERSION :
      java version "1.6.0_10"
      Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
      Java HotSpot(TM) Server VM (build 11.0-b15, mixed mode

      ADDITIONAL OS VERSION INFORMATION :
      SunOS neptune 5.10 Generic_118833-33 sun4u sparc SUNW,A70

      A DESCRIPTION OF THE PROBLEM :
      Setting the background color of a JEditorPane does not have any effect when using the Nimbus L&F.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run the attached test case. Commenting out the call to useNimbusLookAndFeel shows that the background color *is* honored with Ocean L&F.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expected the background color of the editor pane to be red.
      ACTUAL -
      The background color of the editor pane was white.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import javax.swing.*;

      public class EditorPaneBug {
          private static void startGUI() {
              JEditorPane editorPane = new JEditorPane();
              editorPane.setContentType("text/plain");
              editorPane.setEditable(false);
              editorPane.setText("This is some simple text.");

              editorPane.setForeground(java.awt.Color.GREEN);
              editorPane.setBackground(java.awt.Color.RED);

              JFrame frame = new JFrame("Editor Pane Bug");
              frame.getContentPane().add(editorPane, BorderLayout.CENTER);
              frame.setSize(750, 450);
              frame.setLocationRelativeTo(null);
              frame.setVisible(true);
          }

          private static void useNimbusLookAndFeel() {
              try {
                  UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
              } catch (Exception ex) {
                  ex.printStackTrace(System.err);
                  System.exit(1);
              }
          }

          public static void main(String args[]) {
              SwingUtilities.invokeLater(new Runnable() {
                  @Override public void run() {
                      useNimbusLookAndFeel();
                      startGUI();
                  }
              });
          }
      }
      ---------- END SOURCE ----------

            psadhukhan Prasanta Sadhukhan
            igor Igor Nekrestyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: