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

REGRESSION: ColorChooser loses preview when change LandF in Java5

XMLWordPrintable

    • b105
    • x86
    • linux, windows_xp
    • Verified

        FULL PRODUCT VERSION :
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
        Java HotSpot(TM) Server VM (build 1.5.0-b64, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows XP [Version 5.1.2600]
        SunOS raptor 5.9 Generic_117171-07 sun4u sparc SUNW,Sun-Fire-480R


        A DESCRIPTION OF THE PROBLEM :
        When using a JColorChooser, performing a UIManager.setLookAndFeel() removes the preview of the color from the bottom of the JColorChooser. Works fine in java 1.4, but is broken in java5, on both solaris and windows.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Create a new Swing JFrame, with a JButton and a JColorChooser, and on button click, have the UIManager set the look and feel to something else.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Look and feel changes, with all components being updated (including the preview of the JColorChooser)
        ACTUAL -
        Look and feel changes, but removes the preview completely from the JColorChooser, and does not replace it when going back to the original look and feel.

        REPRODUCIBILITY :
        This bug can be reproduced always.

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

        public class Broken
        {
        static int currentLookAndFeel = 0;

        public static void createAndShowGui()
        {
        final JFrame frame = new JFrame("Broken.");
        JPanel panel = new JPanel();
        JColorChooser colors = new JColorChooser();
        JButton button = new JButton("change LandF");

        button.addActionListener(new ActionListener()
        {
        public void actionPerformed(ActionEvent e)
        {
        currentLookAndFeel++;
        String sebLookAndFeel = UIManager.getInstalledLookAndFeels()[currentLookAndFeel % UIManager.getInstalledLookAndFeels().length].getClassName();
                         try
                         {
                         UIManager.setLookAndFeel(sebLookAndFeel);
                         }
                         catch (Exception ex) {}
                         SwingUtilities.updateComponentTreeUI(frame);
        frame.pack();
        }
        });

        panel.add(colors);
        panel.add(button);
        frame.getContentPane().add(panel);
        frame.pack();
        frame.setVisible(true);
        }

        public static void main (String[] args)
        {
        javax.swing.SwingUtilities.invokeLater(new Runnable()
        {
        public void run()
        {
        createAndShowGui();
        }
        });
        }
        }
        ---------- END SOURCE ----------

        Release Regression From : 1.4.2
        The above release value was the last known release where this
        bug was known to work. Since then there has been a regression.

              malenkov Sergey Malenkov (Inactive)
              gmanwanisunw Girish Manwani (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: