How to stop editing with DefaultCellEditor when a separate JBtton is pressed

前端 未结 3 1015
谎友^
谎友^ 2020-12-21 01:23

I got a table with a custom TableCellEditor (extending DefaultCellEditor) with a JFormattedTextField as the editor component.

Now I got problem: when I press a separ

相关标签:
3条回答
  • 2020-12-21 01:29

    Thanks asalamon74, that works quite nicely.

    There's debate over the thing at Sun Bug Database : Bug 4724980: JTable: Add API to control what happens to edits when table loses focus. (also other bug entries are found). The terminateEditOnFocusLost turns on "commit-or-cancel" behaviour that can be seen at the Java sources at the class JTable$CellEditorRemover

    And yes, it's somewhat strange that it isn't documented at the APIs etc...

    0 讨论(0)
  • 2020-12-21 01:45

    Had also more issues with these things, see the question Java Swing : changing JTree selection while editingstopCellEditing() : how to get stopCellEditing() called before TreeListeners:valueChanged?

    0 讨论(0)
  • 2020-12-21 01:49

    You may try

    jtable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

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