JDK-6199676 : REGRESSION: ColorChooser loses preview when change LandF in Java5
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.2,5.0,6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux,windows_xp
  • CPU: x86
  • Submitted: 2004-11-24
  • Updated: 2017-05-16
  • Resolved: 2011-03-08
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.
Other JDK 7
1.4-poolResolved 7 b105Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
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.

Comments
EVALUATION Contribution forum : https://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?forumID=1463&messageID=15303
06-09-2006

EVALUATION Seems the problem is introduced be fix #4759306 We add previewPanelHolder in the installUI() method and then remove it in installPreviewPanel() it happeds because we check layoutSize = new BorderLayout().minimumLayoutSize(previewPanel); which is always equals to (0,0) if previewPanel.getInsets() is (0,0,0,0) I am absolutely agree with evaluation to bug #5029286 which suggested not to check preview panel size at all and removing preview panel by setPreviewPanel(null) ###@###.### 2004-12-26 16:37:22 GMT
26-12-2004