我正在使用 Windows 7,试图运行下面这个简单的程序,但它总是抛出异常
Exception in thread "main" java.lang.NoSuchFieldError: privateKey
at java.awt.Component.initIDs(Native Method)
at java.awt.Component.<clinit>(Unknown Source)
at com.streamer.Test.main(Test.java:16)
SSCCE 是
import java.util.Vector;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
public class Test{
public static void main(String args[])
{
JFrame frame = new JFrame("JFrame Source Demo");
final DefaultTableModel model = new DefaultTableModel(new String[] {
"Id", "Name", "Desg" }, 0);
final JTable table = new JTable(model);
JScrollPane scrollpane = new JScrollPane(table);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(scrollpane);
frame.pack();
frame.setVisible(true);
Vector vec = new Vector();
vec.add("1122");
vec.add("Iraneee");
vec.add("Dev");
model.insertRow(0, vec);
}
}