See my method
public void removeRow(int[] selectedRow) {
int len = selectedRow.length;
for(int i=0; i<len; i++) {
data.remove(selectedRow[i]);
}
fireTableDataChanged();
}
this is the error callstack
Exception in thread “AWT-EventQueue-0” java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.remove(ArrayList.java:387)
at table.MyTableModel.removeRow(MyTableModel.java:89)
at table.Tables$2.actionPerformed(Tables.java:61)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
I am using static ArrayList data as data holder
The problem is that when you remove a row, your tables indices are adjusted/decremented on each remove resulting in the
IndexOutOfBoundsException. You could remove the rows in reverse order to guard against this: