I've been trying to delete a row from my JTable without complete success. My problem is that while the row is removed from both the model and the view, the view is showing the wrong value. Here are the steps to reproduce my issue:
1. Display a single row in a JTable with all cells populated with data. 2. Click a button which adds a new row to the JTable's model. 3. A new empty row is displayed at index 0 and the existing row is positioned at index 1. 4. Enter data into a cell in the new row and keep focus in that cell. 5. Click a button which removes the row at index 0. 6. The new row is removed from the model and the view, but the existing row's column now takes on the value of the removed row's edited cell.
Below is the relevent code:
I'm not sure of what else I need to be doing here in order to get this working. Do I need to implement TableChangeListener and deal perform so magic there?
I take it then that you are receiving user input through some other means such as an input dialog.
My design will allow (try to allow) for the editing of the JTable data directly. The behaviour I've described is pretty strange. What do you think the cause of this "weirdness" is?
Also, I've noticed that you've extended the DefaultTableModel rather than AbstractTableModel. I was under the impression that extensions should be derived from abstract implementation and not the concrete. What made you arrive at that decision?