Deleting The Whole Table problem(Index Out Of Bounds)
michael johanson
Greenhorn
Joined: Feb 08, 2010
Posts: 3
posted
0
the compiler throws me an index out of bounds, i cant find the reason why im getting this, so I tried to remove piece by piece the whole code, until I ended up in this..
but still I cant solve this problem..
when I select all the rows in the Table and press the delete button, it deletes 99% of it, and there is one remains, and an IndexOutOfBoundsException throws me, help with this please
1) Don't use getSelectedRow(); use the real rows that are selected.
2) If you remove a row, all later rows will have their indexes decreased by one. You can prevent this by iterating backwards:
This code does assume that selectedRows will be sorted. If you want to make sure, call Arrays.sort before you start iterating.