swing-触发树单元格编辑事件 [英] swing - Triggering Tree Cell Edit Event
问题描述
我有一个带有可编辑节点的JTree.
我如何以编程方式触发树单元格编辑事件,即调出节点重命名文本框来代替突出显示的节点,就像用户手动突出显示该节点并按F2键一样?
基本上,我想添加一个重命名"菜单项或工具栏按钮,以提示用户树的特定功能,并且我希望它在用户突出显示节点时的功能与F2按键相同.
1)(通过Mouse
/KeyBoard
事件)选择了某个节点,并通过TreeSelectionListener
进行了侦听,然后选定的路径具有唯一的ID >
2)将Swing Action
添加到JMenuItem
(在JPopup
???中,不清楚您的问题,如何从/to结到???)
3)创建类,作废,随便触发
SwingUtilities.invokeLater(new Runnable() {
public void run() {
tree.startEditingAtPath(path);
}
});
4)基于 1) some node is selected (by 2) add 3) create class, void, whatever and to fire 4) based on answer by 这篇关于swing-触发树单元格编辑事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!@Michael Dunn
对我的Mouse
/ KeyBoard
event) and by listening by TreeSelectionListener
, then selected path has unique IDSwing Action
to JMenuItem
(in JPopup
???, not clear from your question, how to get node from /to ???)SwingUtilities.invokeLater(new Runnable() {
public void run() {
tree.startEditingAtPath(path);
}
});
@Michael Dunn
to my question on another forum