I have a JTable
. This table is using a custom model that I designed; the custom model is extends AbstractTableModel
. I have a button which enables a user to delete a selected/highlighted row.
I have tried this code but its giving me a class cast exception -
myTableModel cannot be cast to DefaultTableModel.
Below is the code.
DefaultTableModel model = (DefaultTableModel)table.getModel();
model.removeRow(table.convertRowIndexToModel(table.getSelectedRow()));
model.fireTableDataChanged();`
I have searched the web but it is always DefaultTableModel
- but I have AbstarctTableModel
.
How do we solve this?