想测试一下synth但我的程序能编译就是不能运行,请各位大哥大姐提示一下我TestSynth.java代码如下import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.plaf.synth.SynthLookAndFeel;
import javax.swing.plaf.*;
 
public class TestSynth extends JFrame {
 
public TestSynth() {
super("TestSynth");
try{
  SynthLookAndFeel laf = new SynthLookAndFeel();
  laf.load(TestSynth.class.getResourceAsStream("synth.xml"), TestSynth.class);
  UIManager.setLookAndFeel(laf);
} catch (Exception e) {
System.err.println(e);
}
 
// why this is throwing a NullPointerException.??
try{
FontUIResource defaultFont = new FontUIResource(UIManager.getDefaults().getFont(
                    "TextField.font"));
}catch(Exception e){
e.printStackTrace();
}
 
// this is null thats why the above is throwing nullpointer .. but why it is null???
System.out.println(UIManager.getDefaults().getFont("Label.font"));
 
JLabel label = new JLabel("Enter name : ");
JTextField textField = new JTextField(30);
setLayout(new FlowLayout());
getContentPane().add(label);
getContentPane().add(textField);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(500,500);
setLocation(200,100);
}
 
public static void main(String[] args) {
TestSynth testSynth  = new TestSynth();
testSynth.setVisible(true);
}
 
 
}synth.xml文件如下<synth>
  <style id="textfield">
    <state>
      <color value="pink" type="BACKGROUND"/>
    </state>
    <font name="Lucida" size="12"/>
    <insets top="5" bottom="6" right="7" left="6"/>
  </style>
  <bind style="textfield" type="region" key="TextField"/>
</synth>用javac TestSynth.java 能生成CLASS文件
但java TestSynth.class运行时候出现如下错误
Exception in thread "main" java.lang.NoClassDefFoundError:TestSynth/class
我的JAVA SDK 是1.5的,请问这是什么原因,以上代码是我在网上看的想实验以下