FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Extending OceanTheme to override some of the default fonts causes the attached error.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the test case.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Simple JFrame containing a default JTree.
ACTUAL -
See attached error message.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
com.jdv.insight.client.TestCase$MyTheme/icons/ocean/expanded.gif not found.
com.jdv.insight.client.TestCase$MyTheme/icons/ocean/collapsed.gif not found.
com.jdv.insight.client.TestCase$MyTheme/icons/ocean/collapsed-rtl.gif not found.
Exception in thread "main" java.lang.IllegalArgumentException: null delegate icon argument
at javax.swing.plaf.IconUIResource.<init>(IconUIResource.java:49)
at javax.swing.plaf.metal.OceanTheme$COIcon.<init>(OceanTheme.java:58)
at javax.swing.plaf.metal.OceanTheme$6.createValue(OceanTheme.java:265)
at javax.swing.UIDefaults.getFromHashtable(UIDefaults.java:183)
at javax.swing.UIDefaults.get(UIDefaults.java:128)
at javax.swing.MultiUIDefaults.get(MultiUIDefaults.java:44)
at javax.swing.UIManager.get(UIManager.java:818)
at javax.swing.plaf.basic.BasicTreeUI.installDefaults(BasicTreeUI.java:686)
at javax.swing.plaf.basic.BasicTreeUI.installUI(BasicTreeUI.java:616)
at javax.swing.plaf.metal.MetalTreeUI.installUI(MetalTreeUI.java:95)
at javax.swing.JComponent.setUI(JComponent.java:650)
at javax.swing.JTree.setUI(JTree.java:539)
at javax.swing.JTree.updateUI(JTree.java:555)
at javax.swing.JTree.<init>(JTree.java:510)
at javax.swing.JTree.<init>(JTree.java:408)
at com.jdv.insight.client.TestCase.<init>(TestCase.java:36)
at com.jdv.insight.client.TestCase.main(TestCase.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import javax.swing.plaf.FontUIResource;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.plaf.metal.OceanTheme;
import java.awt.*;
public class TestCase extends JFrame {
public static void main(String[] args) {
try {
MetalLookAndFeel.setCurrentTheme(new MyTheme());
UIManager.setLookAndFeel(MetalLookAndFeel.class.getName());
} catch (Exception e) {
e.printStackTrace();
}
TestCase testCase = new TestCase();
testCase.pack();
testCase.setVisible(true);
}
public TestCase() {
getContentPane().setLayout(new BorderLayout());
JTree tree = new JTree();
JScrollPane scrollPane = new JScrollPane(tree);
getContentPane().add(scrollPane, BorderLayout.CENTER);
}
private static class MyTheme extends OceanTheme {
FontUIResource tahomaFont = new FontUIResource("Tahoma", Font.PLAIN, 11);
public FontUIResource getControlTextFont() {
return tahomaFont;
}
public FontUIResource getUserTextFont() {
return tahomaFont;
}
public FontUIResource getMenuTextFont() {
return tahomaFont;
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
I worked around the problem by copying the icons/ocean subtree from rt.jar into the package structure relative to the new OceanTheme derived class.
###@###.### 11/1/04 23:44 GMT