문제

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.


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

Thanks for the responses.

도움이 되었습니까?

해결책 2

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top