JTable custom cell renderer focus problem

后端 未结 2 1284
一整个雨季
一整个雨季 2021-01-13 17:38

I have a table like this. The second column uses a JTextField renderer and the third column uses a JPasswordField based renderer and editor.

相关标签:
2条回答
  • 2021-01-13 18:25

    Tell the table to automatically commit when losing focus:

    table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    
    0 讨论(0)
  • 2021-01-13 18:45

    So your problem is, that you are still editing the cell. So you have to stop the editing and then the cell will be changed.

    At your button you can get the cell who is being edited with
    TableCellEditor cellEditor = table.getCellEditor();
    then you can stop the editing with
    if(cellEditor!=null){
    cellEditor.stopCellEditing();
    }

    and then you can save the value

    0 讨论(0)
提交回复
热议问题