public boolean isCanDrop(DefaultMutableTreeNode dragTreeNode,   
                             DefaultMutableTreeNode dropTreeNode, JTree jtr) {   
        if (dragTreeNode == null) { //拖动源为空则退出   
            return false;   
        }   
        //设置放置目标为空时不可放置   
        if (dropTreeNode == null ) {   
            return false;   
        }   
        //放置目标是拖动源则退出   
        if (dragTreeNode==dropTreeNode) {   
         return false;   
        }   
       TreePath dragPath = new TreePath (((DefaultTreeModel )jtr.getModel()).getPathToRoot(dragTreeNode));   
       TreePath dropPath = new TreePath (((DefaultTreeModel )jtr.getModel()).getPathToRoot(dropTreeNode));   
       String strDragPath = dragPath.toString();   
       String strDropPath = dropPath.toString();   
       String subDragPath = strDragPath.substring(0,strDragPath.length()-1);   
  
       if (strDropPath.startsWith(subDragPath)) {//放置目标是拖动源的子孙节点   
           return false;   
       }   
       if ( dragPath.getParentPath().toString().equals(strDropPath)) {//放置目标是拖动源的父节点   
           return false;   
       }   
  
       //放置目标是拖动源的父节点则退出   
       if (dragTreeNode.getParent().equals(dropTreeNode)) {   
           return false;   
       }   
  
       return true;   
    }