JDK-4759306 : 1.4.1 REGRESSION: JColorChooser.setPreviewPanel does not remove the old one
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0,1.4.1,1.4.2,5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS:
    linux,windows_98,windows_nt,windows_2000 linux,windows_98,windows_nt,windows_2000
  • CPU: x86
  • Submitted: 2002-10-07
  • Updated: 2002-11-20
  • Resolved: 2002-11-16
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
1.4.2 mantisFixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Name: jk109818			Date: 10/07/2002


FULL PRODUCT VERSION :
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)

FULL OPERATING SYSTEM VERSION :

Windows NT Version 4.0

ADDITIONAL OPERATING SYSTEMS :

Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
In the JColorChooser the setPreviewPanel method does not
have the desired result.

When invoking this method the default PreviewPanel is not
removed from the colorChooser. The new panel is added.

REGRESSION.  Last worked in version 1.4

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just try to add a default previewpanel to the
JColorChooser in any program!

EXPECTED VERSUS ACTUAL BEHAVIOR :
When adding a custom preview panel to the colorChooser the
old default previewPanel of the color chooser is still
visible behind the new component.

Expected result is that the old one is removed from the
colorChooser

Looking at the source of the JColorChooser and
BasicColorChooserUI one can see that a previewPanel holder
is created to hold the default colorchooser preview panel.
  To this panel the preview component is added.
When replacing the previewpanel the BasicColorChooserUI
tries to remove the previewpanelcomponent from
JColorChooser, it is not in there, because it is in the
previewPanelHolder. Then after it has tried to remove it,
it adds the new component to the SOUTH of the
JColorChooser, above the previewPanelHolder, which because
of this is still visible behind the new
previewPanelComponent.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error messages are generated.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;

public class JColorChooserTest extends JFrame {
	public JColorChooserTest(){
		super("JColorChooserTest");
		JColorChooser cch = new JColorChooser();
		JButton button = new JButton("TEST");
		cch.setPreviewPanel(button);
		getContentPane().add(cch);
		setSize(200,200);
		setVisible(true);
	}
	public static void main(String[] args) {
		new JColorChooserTest();
	}

}
---------- END SOURCE ----------

CUSTOMER WORKAROUND :
Manually removing the prieviewPanelHolder JPanel which has
been added when instantiating.

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

(Review ID: 165365) 
======================================================================

Name: jk109818			Date: 10/07/2002


FULL PRODUCT VERSION :
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)


FULL OPERATING SYSTEM VERSION :
Windows 98 [Version 4.10.2222]


A DESCRIPTION OF THE PROBLEM :
Used to be able to hide the default JColorChooser preview
area by sending an empty panel to the setPreviewPanel method
(i.e.,
colorchooser.setPreviewPanel(new JPanel());) Under the new
FCS build of 1.4.1 an empty panel labeled Preview (and
having a messed up border) is now appearing. (see
http://www.adaptiveview.com/cw/img/snaps/bad14102.png as
compared to
http://www.adaptiveview.com/cw/img/snaps/code_generator.png
- these are screenshots of the same jar file running under
the FCS and previous 1.4.1 versions)

REGRESSION.  Last worked in version 1.4.1

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
I'm too busy trying to resolve it (great timing - I just put
out a new version and announced it!)

I'll get back to you with steps/code.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
None. Program runs fine, just looks like $%^#.

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER WORKAROUND :
I'm already recommending on my site that Windows users not
use 1.4.1 due to bug ID 4482430 as the people interested in
my software tend to also like to use "non-standard" fonts.
(Review ID: 164642)
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mantis FIXED IN: mantis INTEGRATED IN: mantis mantis-b08
24-08-2004

EVALUATION Needs to be fixed for mantis. ###@###.### 2002-10-18 Name: keR10081 Date: 11/06/2002 Fix for bug 4461329 caused this regression. See suggested fix for details. ###@###.### ======================================================================
24-08-2004

SUGGESTED FIX Name: keR10081 Date: 11/06/2002 ------- BasicColorChooserUI.java ------- *** /tmp/sccs.XXaqco ?? ??? 1 16:17:40 2002 --- BasicColorChooserUI.java ?? ??? 1 15:50:24 2002 *************** *** 127,132 **** --- 127,136 ---- } previewPanel = chooser.getPreviewPanel(); + if ((previewPanel != null) && (previewPanelHolder != null) && (chooser != null) && (previewPanel.getSize().getHeight()+previewPanel.getSize().getWidth() == 0)) { + chooser.remove(previewPanelHolder); + return; + } if (previewPanel == null || previewPanel instanceof UIResource) { previewPanel = ColorChooserComponentFactory.getPreviewPanel(); // get from table? chooser.setPreviewPanel(previewPanel); ====================================================================== This is not working in 1.5.0-beta also. We should try to get this fixed before beta2/fcs. ###@###.### 2004-03-29 ###@###.### 2004-04-01
29-03-2004