【发布时间】:2015-04-09 04:29:00
【问题描述】:
我有一个JTable,并且该表的一列正在使用JComboBox 作为编辑器。这样它工作得很好。然后我继续使用this jar file here 在我的JComboBox 中启用自动完成功能。同样效果很好。
现在我要保存表格中的数据,如下所示;
public void actionPerformed(ActionEvent e) {
File outFile= new File("qoutatio.dat");
try {
FileOutputStream fous=new FileOutputStream(outFile);
ObjectOutputStream obj=new ObjectOutputStream(fous);
obj.writeObject(table);
obj.flush();
obj.close();
} catch (FileNotFoundException ex) {
Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
}
}
};
程序产生以下错误:
run:
Feb 09, 2015 2:13:54 PM quotationGenerator.MainWindow$2 actionPerformed
SEVERE: null
java.io.NotSerializableException: org.jdesktop.swingx.autocomplete.AutoCompleteComboBoxEditor
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:441)
at javax.swing.JComboBox.writeObject(JComboBox.java:1569)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
这表明 jar 文件中的一个类不是Serializable.Understood。我的问题:有没有办法制作这个Serializable?我们如何解决这个问题?
【问题讨论】:
标签: java swing jtable serializable