怎样在一棵树上双击某个节点,然后让这个节点删除并增加到另一个节点上?偶菜鸟,帮忙

解决方案 »

  1.   

    if(e.getSource()==tree)
    {
    TreePath treepath = tree.getSelectionPath();
         if(treepath!=null)
         {
         DefaultMutableTreeNode selection = (DefaultMutableTreeNode)treepath.getLastPathComponent();
         if(selection.isRoot())
    {
    return;
    }
         TreeNode parent = (TreeNode)selection.getParent();
         String nodename = parent.toString();
      
         if(parent!=null&&nodename.equals("酒店房间类型")==false)
         {
         treeModel.removeNodeFromParent(selection); //删除树中的房间
         // treeModel.reload();
         listModel.addElement(selection.toString()); //将删除的房间添加到列表中
         text_fangjianid.setText(list_kaidan.getModel().getElementAt(0).toString());
         }
         }
         }