【发布时间】:2011-08-31 18:36:24
【问题描述】:
我有一个 JTree,用户可以在其中从其他组件中删除元素。当用户将鼠标悬停在树中的节点上时(在“放置模式”期间),最靠近的节点被突出显示。这是在TransferHandler的实现中实现的。
@Override
public boolean canImport(TransferSupport support) {
//Highlight the most near lying node in the tree as the user drags the
//mouse over nodes in the tree.
support.setShowDropLocation(true);
每次选择一个新节点时(也在“放置模式”期间),这将触发一个 TreeSelectionEvent。这反过来将调用我创建的侦听器,该侦听器将查询数据库以获取与该节点相关的详细信息。
现在,我正在寻找一种方法来过滤掉在“放置模式”期间从节点选择中生成的事件。这是一种限制数据库调用的尝试。有人对我如何实现这一点有任何想法吗?
我们将不胜感激!
【问题讨论】:
标签: java swing drag-and-drop jtree