当在树的某个节点上单击右键时如何获取该节点?

解决方案 »

  1.   

    网上找了下, oncontextmenu 是用来检测右键事件的。  当你在树节点进行右击时, 可以使用
    如下:  一个文本框<input type=text oncontextmenu="getChildNodes(this);"><script>
        function getChildNodes(e) {
          // e就是这个节点的对象。
           // 你要编写的代码         return false; //禁用右键默认菜单
    }
    </script>
      

  2.   

    public void mousePressed(MouseEvent e) {
             int selRow = tree.getRowForLocation(e.getX(), e.getY());
             TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
            ......