Name: rmT116609 Date: 07/09/2002
FULL PRODUCT VERSION :
java version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b14)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b14, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows XP [Version 5.1.2600]
DESCRIPTION OF THE PROBLEM :
When calling the method updateUI() of instances of the class javax.swing.JColorChooser an IllegalArgumentException gets thrown if one or more of the defaults chooser panels were removed before.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Execute the attached source code
EXPECTED VERSUS ACTUAL BEHAVIOR :
The expected behaviour is that the BasicColorChooserUI first checks if a chooser panel is available before removing it. Since this does not happen, the actual result is that the exception gets thrown.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.IllegalArgumentException: chooser panel not in this chooser
at javax.swing.JColorChooser.removeChooserPanel(JColorChooser.java:409)
at javax.swing.plaf.basic.BasicColorChooserUI.uninstallDefaultChoosers
(BasicColorChooserUI.java:60)
at javax.swing.plaf.basic.BasicColorChooserUI.uninstallUI
(BasicColorChooserUI.java:88)
at javax.swing.JComponent.setUI(JComponent.java:440)
at javax.swing.JColorChooser.setUI(JColorChooser.java:209)
at javax.swing.JColorChooser.updateUI(JColorChooser.java:220)
at com.incors.bugreports.ColorChooserBug.main(ColorChooserBug.java:14)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import javax.swing.colorchooser.*;
public class ColorChooserBug {
public static void main(String[] args) {
try {
JColorChooser colorChooser = new JColorChooser();
AbstractColorChooserPanel[] colorChooserPanels = colorChooser.getChooserPanels();
colorChooser.removeChooserPanel(colorChooserPanels[0]);
colorChooser.updateUI();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
There are two possible workarounds:
1. Make a subclass of BasicColorChooserUI and check inside the method uninstallDefaultChoosers() if a chooser panel exists before removing it.
2. Make a subclass of JColorChooser and catch the exception silently inside the method removeChooserPanel()
(Review ID: 159004)
======================================================================