JDK-6789980 : JEditorPane background color not honored with Nimbus L&F
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u10
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_10
  • CPU: sparc
  • Submitted: 2009-01-05
  • Updated: 2021-08-19
  • Resolved: 2021-08-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 18
18 b11Fixed
Description
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 ----------

Comments
Changeset: 0c4be76f Author: Prasanta Sadhukhan <psadhukhan@openjdk.org> Date: 2021-08-13 05:12:59 +0000 URL: https://git.openjdk.java.net/jdk/commit/0c4be76f7ff3cd5e32c8eb4e04e6986d5f33fbee
13-08-2021