JDK-6559154 : Reursively disabling JColorChooser causes EDT to hang.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2007-05-18
  • Updated: 2011-01-19
  • Resolved: 2008-07-18
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
Linux andromeda.basis.com 2.6.16-1.2108_FC4 #1 Thu May 4 23:52:01 EDT 2006 i686 i686 i386 GNU/Linux
Also occurs on Windows XP

A DESCRIPTION OF THE PROBLEM :
Swing does not recursively enable or disable complex components.  Because of this, a complex control like the JColorChooser does not disable its sub-components, and the developer must do this if he desires to disable the chooser.

When writing code that does this to a JColorChooser, the sample shows that there is an exception in an image loading thread and this causes the Event Dispatch Thread to hang on a MediaTracker.wait().



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the attached source code.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect the JColorChooser to appear in the dialog with all the subcomponents disabled.
ACTUAL -
The AWT window stops repainting, and an exception appears on stderr.


ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "SyntheticImageGenerator" java.lang.NullPointerException
	at java.awt.image.ImageFilter.setProperties(ImageFilter.java:90)
	at javax.swing.colorchooser.SyntheticImageGenerator.run(SyntheticImage.java:111)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.lang.reflect.InvocationTargetException;

import javax.swing.JColorChooser;
import javax.swing.JDialog;
import javax.swing.SwingUtilities;

public class DisabledColorChooser
{
    public static void main(String[] p_argv) throws InterruptedException, InvocationTargetException
    {
        final JDialog dialog = new JDialog();
        SwingUtilities.invokeAndWait(new Runnable()
        {
            public void run()
            {
                JColorChooser cc = new JColorChooser();
                setEnabledRecursive(cc, false);
                dialog.add(cc);
                dialog.setVisible(true);
            }
        });
    }

    private static void setEnabledRecursive(Container p_container, boolean p_enabled)
    {
        Component[] comps = p_container.getComponents();
        for (int i = 0; i < comps.length; ++i)
        {
            comps[i].setEnabled(p_enabled);
            if (comps[i] instanceof Container)
                setEnabledRecursive((Container)comps[i], p_enabled);
        }
    }
}
---------- END SOURCE ----------

Comments
EVALUATION The problem is in the SyntheticImage class that is used to draw the color diagram. This class was rewritten in the fix for the 6552812 bug.
18-07-2008