Hi have a Jtable with a specific cell rendered model for one column. This model, just put buttons in this column instead of text data.
The first display of the table works well. WHen I’m using a function that change the order of the content, the model is still called for this column (the redraw is forced through a call to fireTableDataChanged()).
Now, I want that the delete key delete the current row of my table. For this, I’m using the following code:
public void keyTyped(KeyEvent arg0) {
if (arg0.getKeyChar() == KeyEvent.VK_DELETE) {
int currentRow = this.m_data.currentRow();
if (currentRow >= 0) {
this.m_data.deleteRow(currentRow);
System.out.println("mise a jour après destruction de ligne");
this.fireTableRowsDeleted(currentRow, currentRow);
}
}
}
(m_data is my table model).
Surprisingly, the data are updated (row has disappeared), but the first column is empty. And my traces show that just getValueAt() are called. getTableCellRendererComponent() is not called.
I have tried to fire fireTableDataChanged() instead of fireTableRowsDeleted() but it is the same thing. Hence it does not seem to be relative to the fire function. Any idea about the origin of this problem, and the way to solve it?
Thanks in advance.
OK, finally I found the problem. I had a ListSelectionListener, that, in somes circonstances, sent a fireTableCellUpdated(-1,0). This is this command that “stupid Java” interpreted as “remove the table rendering”.