这是对这些先前问题的后续:
- 当按下单独的 JButton 时如何停止使用默认 CellEditor 进行编辑 https://stackoverflow.com/questions/377924/how-to-stop-editing-with-defaultcelleditor-when-a-separate-jbtton-is-pressed
- Sun Bug 4724980:JTable:添加 API 来控制表失去焦点时编辑的情况。 https://bugs.java.com/bugdatabase/view_bug?bug_id=4724980
当我使用terminateEditOnFocusLost
属性,如下所示,当表格失去焦点时,我的 CellEditor 正确停止编辑:
jtable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
它也适用于我的 JButton。这stopCellEditing()
为我的 TableCellEditor 调用方法before处理按钮按下动作。但是当我将它与 JTree 一起使用并且树选择发生变化时,TreeSelectionListener.valueChanged
方法被称为before stopCellEditing()
.
有谁知道有没有办法强制stopCellEditing()
首先被调用,或者我应该为这个问题找到一些解决方法?
JTree
没有类似的客户财产Swing
.
But JXTree
,派生类JTree
, in SwingX
does: invokeStopEditing
.
如果你不能使用SwingX
,你可以随时查看源代码JXTree
看看这个 StopEditing 机制是如何工作的:JXTree SwingX 1.0 API Documentation and Javadoc http://www.jdocs.com/swingx/1.0/org/jdesktop/swingx/JXTree.html (go to Source tab)
特别是,从线开始974
,创建一个监听器来监听“permanentFocusOwner
“ 属性变化KeyboardFocusManager
etc...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)