如题,在每个Tree的node上点击右键,都会出现一个带有3个菜单选项的menu出来,是在javax.swing中的编程,在线等解!

解决方案 »

  1.   

    //树的鼠标点击事件
        public void treDate_mouseClicked(MouseEvent e) {
            //获取选中的节点
            TreePath path = this.treDate.getPathForLocation(e.getX(), e.getY());
            if (path == null) {
                return;
            }
            //弹出右键菜单
            if (e.getButton() == 3) {
                    this.pmTree.show(this.treDate, e.getX(), e.getY());
            }
        }
      

  2.   

    TreePath path = this.treDate.getPathForLocation(e.getX(), e.getY());
            if (path == null) {
                return;
            }
    这部分就够了~thank you~