DefaultTableModel Serialization
Hey there, I'm attempting to store a JTable's TableModel by Serializing a DefaultTableModel object.
The API says that DefaultTableModel implements the Serialization interface, but when I try and run my program
I get the following exception.
java.io.NotSerializableException: javax.swing.JTable$CellEditorRemover.
Anyone get any ideas?
Re: DefaultTableModel Serialization
The CellEditorRemover class does not implement Serializable.
Re: DefaultTableModel Serialization
I'm afraid I'm not with you.
How would I tell it not to serialize that? I'm attempting to serialize a DefaultTableModel object which said it was serializable, so that's left me scratching my head.
Re: DefaultTableModel Serialization
Where does the CellEditorRemover class come from?
When you attempt to Serialize an object it also Serializes all the sub-Objects as well. Therefore all the sub-Objects must implement Serializable as well. From the error message you posted it suggests that there is at least one CellEditorRemover object somewhere in your Table or TableModel and that class does not implement Serializable.
Re: DefaultTableModel Serialization
From the limited resources found via Google, I've gathered that CellEditorRemover belongs to JTable more than TableModel, I've never manually registered a CellEditorRemover object with any of them, and I've looked for methods which might be able to detach/disable CellEditorRemover but to no avail. So I'm still dumbfounded as to what it essentially means. Why would a class be serializable when its enclosed class isn't?
Re: DefaultTableModel Serialization
The JTable that you are using is it a custom class? The CellEditorRemover class is not a nested class of the JTable class in the standard API. It would seem you are using a JTable class from a third party.
Re: DefaultTableModel Serialization
Not at all.
I'm simply using the default JTable class, not sub-classing it or anything alike.
Re: DefaultTableModel Serialization
JTable (Java Platform SE 6)
The above link is to the JTable in the Java API and it only has 3 nested classes, none of them are CellEditorRemover.
JTable
The above link is to another JTable in what must be a different API. It has 12 nested classes and one of them is CellEditorRemover.
I'm at a loss.
Re: DefaultTableModel Serialization
Yeah me too :)
Code java:
public JTable getSemester1JTable() {
final JTable TABLE = new JTable();
TABLE.setModel(MODEL);
MODEL.setColumnIdentifiers(getColumnHeader());
DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer();
rightRenderer.setHorizontalAlignment(JLabel.CENTER);
TableColumn column = null;
for (int i = 0; i < 10; i++) {
column = TABLE.getColumnModel().getColumn(i);
column.setResizable(false);
column.setCellRenderer(rightRenderer);
}
TABLE.getTableHeader().setForeground(Color.BLUE);
TABLE.setShowVerticalLines(true);
TABLE.setSelectionBackground(Color.PINK);
TABLE.setSelectionForeground(Color.GREEN);
TABLE.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
TABLE.setPreferredScrollableViewportSize(new Dimension(1500, 400));
TABLE.setFillsViewportHeight(true);
TABLE.setRowHeight(80);
TABLE.setRowSelectionAllowed(false);
return TABLE;
}
Thats the code I use, and In another class I simply have: JTable table = myObject.getSemester1JTable();