In a class called HistoryPanel
I have a static JTable called resultsTable
with a static DefaultTableModel called tableModel
. The table has a custom cell editor:
resultsTable.getColumn("Delete").setCellEditor(new DeleteButtonEditor(new JCheckBox()));
Inside, naturally, I override these two methods like this:
public Object getCellEditorValue()
{
if (isPushed)
{
HistoryPanel.tableModel.removeRow(HistoryPanel.resultsTable.getSelectedRow());
}
}
protected void fireEditingStopped()
{
super.fireEditingStopped();
}
The exception is being thrown ONLY when I try to remove the last row of the resultsTable. When I'm removing a row that is not the last one it works perfectly. The exception is:
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 1 >= 1
And the line of code that causes the exception is:
super.fireEditingStopped();
Can anyone help me? How can I avoid this exception