I've added a new method to my TableModel for JTable which doesn't seem to work as I expected. Note the following code:
What's interesting in this class is that the removeRow(int row) method works fine. Removing a single row with this method does the job. All I'm really doing is replacing the data array with a new instance of Object data. The removeAllData() method does the same thing, only it replaces the data with a new instance of Object with no elements. At runtime, if the JTable is populated and I call removeAllData() on the TableModel nothing changes in JTable. The old data is still displaying. What am I dong wrong?
I'm just guessing: try to replace your 17th line with
Arguments to fireTableRowsDeleted are inclusive, you're therefore advertising deletion of a row which is actually beyond the last row.
You could also call fireTableDataChanged instead, it tells the table all data (but not the structure) of a table has changed.
A related bug seems to be there: when removing a single row, you don't resize the array, and you use its length to count rows, eg. in removeAllData). I strongly suggest to keep your data in an ArrayList instead. You'll save yourself a lot of hassle with maintaining the array "by hand".
Though it could easily be a list of arrays, I'd create a class to hold data for one row and use a list of instances of this class, but that's a different story.