Search code examples
javaswinguser-interfacejtabletablecelleditor

Remove focus on editable jtable cell


When double click on editable cell of jtable it shown as here.

follow

what i need is if user click mouse outside table of press a button before entering the value then existing value should be auto entered and output should be shown as follow.

after

Any help or suggestion would be greatly appreciated.


Solution

    1. for DefaultTableModel works by default myJTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

    2. override stopCellEditing()

      a) public boolean stopCellEditing()

      b) myJTable.getCellEditor().stopCellEditing();

      c) myJTable.getCellEditor(row, col).stopCellEditing();