请告诉我如何在叶子的父节点上进行事件处理。
这里我想在RRITG04节点上进行事件处理。
mobileEnablerTxnListTree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent p_evt) {
if (p_evt.getButton() == MouseEvent.BUTTON3) {
DefaultMutableTreeNode l_selected_node = (DefaultMutableTreeNode) mobileEnablerTxnListTree
.getLastSelectedPathComponent();
if (l_selected_node != null && l_selected_node.isRoot())
meTxnListTreeRightClickNewEntity(p_evt);
if (l_selected_node != null && l_selected_node.isLeaf())
meTxnListTreeRightClick(p_evt);
}
}
});
由于
答案 0 :(得分:0)
public void mouseClicked(MouseEvent p_evt) {
DefaultMutableTreeNode l_selected_node = (DefaultMutableTreeNode) returnMobileEnablerFieldMapTree
.getLastSelectedPathComponent();
if (p_evt.getButton() == MouseEvent.BUTTON3) {
if (l_selected_node != null
& l_selected_node.equals(l_selected_node
.getLastLeaf().getParent())) {
Do whatever you want ...........
}
}
我通过这样做解决了我的问题。
由于