K. Tsang wrote:Hi all, I have the following
Now after I click the delete button, that deleted record is still displayed in the table view but as "java.lang.Object@..." for the field. I want to completely remove the just deleted row from the view.
Also I noticed if there are say 20 records, I delete the 5th record. The 20th record disappears with the 5th record display as "java.lang.Object...". If I managed to remove the 5th record, would I able to see the 20th record again?
Oh the removeRow method is practically the same as the DefaultTableModel implementation. But it doesn't look right.
MyTableModel.removeRow() needs to call the
fireTableRowsDeleted() method. What this does is notify the listeners (i.e. the JTable) so they can update themselves.
Btw, it's hard to tell from what you've shown us, but it appears that you are storing all the data twice: once in MyTableModel's
map and once in the
data object. Wouldn't it be easier to just store it once? For instance, MyTableModel could simply refer to
data.