java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 8 at
The error is that you are trying to use an index value of -1. It is a reasonable guess that the problem is caused by the line:
int selectedRows = mainTable.getSelectedRow();
So if
getSelectedRow
does not find a row with the selected status, it will return -1. So you should be able to check that, both visually, and within your code.
If that is not the case then you need to use the debugger to get exact details.