Insubstantial / insubstantial

Swing look-and-feel library and assorted widgets
193 stars 58 forks source link

Color chooser setColor not working in Java 7 #105

Open pengfoong opened 11 years ago

pengfoong commented 11 years ago

In Java 7, with skin set, JColorChooser.setColor does not change the color selected in the chooser panels. This happens for all the chooser panels.

All the chooser panels will show the white color no matter what color is set. For example, the RGB slider will all be 255, 255 ,255. However, the bar next to the tool that let you pick color from anywhere from screen works. It changes color when setColor is called.

This happens in 7.1 and 7.2. My machine is a windows 7 x64 if it matters. The problem doesn't appear in Java 6.

Here is a sample application to replicate the problem. Also, the color chooser in the demo doesn't work. Most of the items are invisible. It works on Java 6 though.

public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); javax.swing.SwingUtilities.invokeLater(new Runnable() { @Override public void run() { SubstanceLookAndFeel.setSkin(new OfficeBlue2007Skin()); JColorChooser chooser = new JColorChooser(); chooser.setColor(Color.yellow); JDialog dialog = JColorChooser.createDialog(null, "title", true, chooser, null, null); dialog.setVisible(true); } }); }

enwired commented 11 years ago

I can also reproduce this problem. It works fine with Java 6 (1.6.0_30-b12), but not with Java 7 (1.7.0_07-b11). I'm also on Windows 7 x64.

There also some layout-related problems with this special color chooser UI. (I may file bugs for those later.) I think there is a substance property you can set to make it use the standard color-chooser UI, but I've forgotten what that constant is.

ebourg commented 11 years ago

You can work around this issue by setting the ColorChooser.defaultChoosers UI property :

UIManager.put("ColorChooser.defaultChoosers",
        new String[]{
                "org.pushingpixels.substance.internal.contrib.randelshofer.quaqua.colorchooser.SwatchesChooser",
                "org.pushingpixels.substance.internal.contrib.xoetrope.editor.color.ColorWheelPanel"
        });