JDK-8033786 : White flashing when opening Dialogs and Menus using Nimbus with dark background
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7u4,8
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86
  • Submitted: 2014-02-06
  • Updated: 2017-05-24
  • Resolved: 2014-06-15
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 8 JDK 9 Other
8u20 b20Fixed 9Fixed openjdk7uFixed
Description
FULL PRODUCT VERSION :
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b121)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b63, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Darwin Kernel Version 12.5.0: Sun Sep 29 13:33:47 PDT 2013; root:xnu-2050.48.12~1/RELEASE_X86_64 x86_64

A DESCRIPTION OF THE PROBLEM :
when opening JDialogs or JMenus with Nimbus Look & Feel and the L&F color changed so a dark background is used, JDialogs and JMenus are first painted white and then painted in their designated color, leading to an ugly "flashing" effect.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use the test code given below and click on the button.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JDialog and JMenu should immediately be painted in their designated color.
ACTUAL -
see description (white flashing)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.plaf.ColorUIResource;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestDarkNimbus {

    public static void main(String[] args) throws Exception {

        for(LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()){
            if(info.getName().startsWith("Nimbus")){
                System.out.println("Setting Look & Feel to " + info.getName());
                UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }

        UIDefaults d = UIManager.getDefaults();
        d.put("control", new ColorUIResource(54, 54, 54));
        d.put("text", new ColorUIResource(214, 214, 214));
        d.put("nimbusBlueGrey", new ColorUIResource(44, 44, 44));
        d.put("nimbusBase", new ColorUIResource(54, 54, 54));
        d.put("nimbusFocus", new Color(71, 85, 101));
        d.put("nimbusLightBackground", new ColorUIResource(54, 54, 54));
        d.put("nimbusSelectionBackground", new ColorUIResource(51, 65, 81));
        d.put("nimbusSelection", new ColorUIResource(51, 65, 81));

        final JFrame frame = new JFrame(TestDarkNimbus.class.getSimpleName());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JButton button = new JButton("Test Dialog Flashing");
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JOptionPane.showMessageDialog(frame.getContentPane(), "Flash !!!!!!!!!!!!", "Flash demo",
                        JOptionPane.INFORMATION_MESSAGE);
            }
        });
        frame.getContentPane().add(button);
        frame.pack();
        frame.setLocation(500, 500);
        frame.setVisible(true);
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
none found so far


Comments
Two problems here. There is a lag between the showing of the window and the first repaint action. We should change the color of the native window to the color of the Component(to the dark color in this case). The problem that JDialog does not set background color to the peer, like JFrame does.
09-06-2014

Release team: Approved for deferral.
06-02-2014

8-defer-request: not a regression and not a jck. Can be postponed to 8u20.
06-02-2014