Want to deselect table cell

196 Views Asked by At

In a JTable, if I type a value in table cell and when I click the button to print the value of that cell. But I input a value and immediately click the button it does not print. If I press enter after the input a value in cell and click on the button, now it prints well. How can I prevent this in my table ?

1

There are 1 best solutions below

1
On

In a JTable, if I type a value in table cell and when I click the button to prints the value of that cell. But I input a value and immediately click the button it's not print. If I press enter after the input a value in cell and click on the button, now it's print well. How can I prevent this in my table ?

my shots in the dark

  • set myTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); for DefaultCellEditor

    or

  • override public boolean stopCellEditing() { for any custom editors types e.g. XxxCellEditor implements TableCellEditor {