White flashing when opening Dialogs, Menus etc.

Robert Krüger krueger at lesspain.de
Wed Feb 5 07:01:08 PST 2014


This is a simple test case for you to reproduce the flashing for
opening a Dialog. It's basically the same for JMenus.

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);
    }
}

On Mon, Jan 6, 2014 at 6:49 PM, Robert Krüger <krueger at lesspain.de> wrote:
> Hi,
>
> we are using a customized Nimbus L&F (the customization is mostly
> color changes) with dark backgrounds. Since we migrated our product
> from Apple JDK 6 to OpenJDK 8 each JMenu or JDialog opens and first
> draws a white rectangle that is then quickly replaced by the real
> content, which has a rather unprofessional feel.
>
> Has anyone had a similar problem and maybe a workaround other than not
> having a dark background? Is there a known Jira issue I can follow?
>
> I am currently running build 121 in development on Mac OS 10.8.
>
> Thanks,
>
> Robert


More information about the macosx-port-dev mailing list