-
Bug
-
Resolution: Fixed
-
P4
-
6
-
b27
-
x86
-
windows_xp
-
Not verified
FULL PRODUCT VERSION :
1.6.0-beta-b59
A DESCRIPTION OF THE PROBLEM :
If you call JColorChooser#setSelectionModel the color chooser doesn't show a preview anymore. BasicColorChooserUI registers a listener for updating the preview panel only with the initial selection model, but doesn't reregister this listener if the color chooser's selection model changes.
BasicColorChooserUI has a property change handler that should listen to the JColorChooser's property JColorChooser.SELECTION_MODEL_PROPERTY.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Construct a JColorChooser
JColorChooser colorChooser = new JColorChooser(Color.RED);
2) Change the selection model.
colorChooser.setSelectionModel(new DefaultColorSelectionModel(Color.WHITE));
3) Display the color chooser, e.g.
JDialog dialog = JColorChooser.createDialog(null, "Choose", true, colorChooser, null, null);
dialog.show();
4) Choose a color.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After step 3, the preview panel should display WHITE, not RED.
After step 4, the preview shall display a preview of the selected color.
ACTUAL -
After step 3, the preview panel displays RED.
When choosing a color, the preview panel displays RED.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Color;
import javax.swing.JColorChooser;
import javax.swing.JDialog;
import javax.swing.colorchooser.DefaultColorSelectionModel;
public class BasicColorChooserUIBug {
public static void main(String[] args) {
JColorChooser colorChooser = new JColorChooser(Color.RED);
colorChooser.setSelectionModel(new DefaultColorSelectionModel(Color.WHITE));
JDialog dialog = JColorChooser.createDialog(null, "Choose", true, colorChooser, null, null);
dialog.show();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
1) Don't use JColorChooser#setSelectionModel. Use only JColorChooser(ColorSelectionModel)
2) Use a look&feel that fixes the bug, i.e. that listens to changes of the color selection model to reregister the preview listener.
1.6.0-beta-b59
A DESCRIPTION OF THE PROBLEM :
If you call JColorChooser#setSelectionModel the color chooser doesn't show a preview anymore. BasicColorChooserUI registers a listener for updating the preview panel only with the initial selection model, but doesn't reregister this listener if the color chooser's selection model changes.
BasicColorChooserUI has a property change handler that should listen to the JColorChooser's property JColorChooser.SELECTION_MODEL_PROPERTY.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Construct a JColorChooser
JColorChooser colorChooser = new JColorChooser(Color.RED);
2) Change the selection model.
colorChooser.setSelectionModel(new DefaultColorSelectionModel(Color.WHITE));
3) Display the color chooser, e.g.
JDialog dialog = JColorChooser.createDialog(null, "Choose", true, colorChooser, null, null);
dialog.show();
4) Choose a color.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After step 3, the preview panel should display WHITE, not RED.
After step 4, the preview shall display a preview of the selected color.
ACTUAL -
After step 3, the preview panel displays RED.
When choosing a color, the preview panel displays RED.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Color;
import javax.swing.JColorChooser;
import javax.swing.JDialog;
import javax.swing.colorchooser.DefaultColorSelectionModel;
public class BasicColorChooserUIBug {
public static void main(String[] args) {
JColorChooser colorChooser = new JColorChooser(Color.RED);
colorChooser.setSelectionModel(new DefaultColorSelectionModel(Color.WHITE));
JDialog dialog = JColorChooser.createDialog(null, "Choose", true, colorChooser, null, null);
dialog.show();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
1) Don't use JColorChooser#setSelectionModel. Use only JColorChooser(ColorSelectionModel)
2) Use a look&feel that fixes the bug, i.e. that listens to changes of the color selection model to reregister the preview listener.
- relates to
-
JDK-6707406 BasicColorChooserUI tests throw NPE while getColorSelectionModel if isPropertyChanged() returns true
-
- Closed
-