开发者

Cell editor not exiting when row is deleted

I have a JTable with a several columns, one of which is has a custom renderer to display 3 buttons in a JPanel as well as a custom editor to allow them to be clickable. One of the buttons sends a delete command to our server for that row id then reloads the table data from the server by clearing the data model and loading data again. When this happens the cell with the 3 buttons continues to display (but not the rest of the row) until I click another button in another row even though the row is gone.

I've set putClientProperty("terminateEditOnFocusLost", Boolean.TRUE) but changing focus to another component does not help.

I've tried deleting the row itself before refreshing the data (even deleted all the rows) and made sure to call fireTableRowsDeleted().

I've also tried calling the cancelCellEditing() and stopCellEditing() functions of the TableCellEditor and even manually setting the editing row/column to another cell.

Any help would be greatly appreciated.


开发者_如何学JAVAOk, so I figured it out. I ended up calling removeEditor() on the table and that fixed it.

Thanks for the responses.


I've set putClientProperty("terminateEditOnFocusLost", Boolean.TRUE) but changing focus to another component does not help.

That method should be invoked when you create the table, not in the actionPerformed method when you click the button.


Ok, so I figured it out. I ended up calling removeEditor() on the table just before the data refresh and that fixed it.

Thanks for the responses.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜