Selecting "Choose only web-safe colors" makes it impossible to re-open the JColorChooser panel.
ed-erwin-tf opened this issue · 0 comments
ed-erwin-tf commented
Radiance 7.0.2, Theming, Java 11, Windows 10
In the HTML Sliders color chooser, selecting "Choose only web-safe colors" can make it impossible to re-open that color chooser dialog after it is closed.
You can reproduce the problem like this:
- call JColorChooser.showDialog(null, "Pick a color", Color.yellow);
- user selects "HTML Sliders" and selects "Choose only web-safe colors".
- user selects "OK"
- again call JColorChooser.showDialog(null, "Pick a color", Color.yellow);
The color chooser will not open the second time. A stack trace is logged.
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Cannot invoke "org.pushingpixels.radiance.theming.internal.contrib.randelshofer.quaqua.colorchooser.HTMLColorSliderModel.setWebSaveOnly(boolean)" because "this.ccModel" is null
at org.pushingpixels.radiance.theming.internal.contrib.randelshofer.quaqua.colorchooser.HTMLChooser.webSaveChanged(HTMLChooser.java:414)
at java.desktop/javax.swing.AbstractButton.fireItemStateChanged(AbstractButton.java:2000)
at java.desktop/javax.swing.AbstractButton$Handler.itemStateChanged(AbstractButton.java:2320)
The bug is in incorrect code for initializing the HTMLChooser class.
- The method initComponents(), called from the constructor, adds a listener to the webSaveCheckBox.
- The constructor calls webSaveCheckBox.setSelected(lastWebSaveSelectionState);
- An event calls webSaveChanged()
- It tries to call ccModel.setWebSaveOnly(), but the variable ccModel is still null.
There are multiple ways to fix this. A simple one is to modify the constructor to make sure that the ccModel is constructed prior to modifying the value of webSaveCheckBox.setSelected().