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

White flashing when opening Dialogs and Menus using Nimbus with dark background

    Details

    • Subcomponent:
    • Resolved In Build:
      b20
    • CPU:
      x86
    • OS:
      os_x

      Backports

        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

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  serb Sergey Bylokhov
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: