RSST
RSST

Reputation: 79

Want to deselect table cell

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 ?

Upvotes: 1

Views: 190

Answers (1)

mKorbel
mKorbel

Reputation: 109815

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 {

Upvotes: 3

Related Questions