Reputation: 110
I have a jtable, in which I keep certain information, and I have a 'clear' button that cleans all the information in the table.
The problem is, when I double click on a cell in the table and then I press the clear button, the table is emptied correctly but the selected cell continues appearing in the table as if it had not been deleted. As you can see in the next screenshot.
This is the java code i use to clear the information of the jtable:
public void resetArea(JTable tabla) {
DefaultTableModel dm = (DefaultTableModel)tabla.getModel();
while(dm.getRowCount() > 0) {
dm.removeRow(0);
}
}
Upvotes: 0
Views: 80
Reputation: 38
Try this
DefaultTableModel dm = (DefaultTableModel)tabla.getModel();
while(dm.getRowCount() > 0) {
dm.removeRow(dm.getRowCount()-1);
}
Upvotes: 1
Reputation: 109613
That is caused as the cell editor is still shown. First do:
tabla.removeEditor();
Upvotes: 2