-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.4.2
-
x86
-
windows_xp
Name: jl125535 Date: 08/26/2003
FULL PRODUCT VERSION :
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
The Swing property Tree.selectionBorderColor in the Windows look-and-feel is set to an object of the wrong class (should be subclass of java.awt.Color).
I think that part of the contract of UIDefaults is that if I ask for a property that's named '*Color' then I should get a Color (or a subclass).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the code given in the Source Code section.
If you run it with JDK 1.3.1 you get:
[C:/work] java -Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel Test
o = javax.swing.plaf.ColorUIResource[r=255,g=255,b=0]
If you run with JDK 1.4.2 you get:
[C:/work] C:/j2sdk1.4.2/bin/java -Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel Test
o = com.sun.java.swing.plaf.windows.WindowsBorders$DashedBorder@87a5cc
Note that running "java Test" without setting swing.defaultlaf produces the expected result.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Both outputs should be the same
ERROR MESSAGES/STACK TRACES THAT OCCUR :
ClassCastException when casting the result to java.awt.Color
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.UIManager;
public class Test
{
public static void main(String[] argv)
{
Object o =
UIManager.getLookAndFeel().
getDefaults().get("Tree.selectionBorderColor");
System.err.println("o = " + o);
System.exit(0);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Currently, I catch the exception and ignore the property. However, I think this may cause weird problems to other people if it happens inside of third party libraries.
(Incident Review ID: 199870)
======================================================================
- relates to
-
JDK-4674205 Windows L&F: JTable and JTree selection should not be framed in yellow
-
- Resolved
-