public boolean addRoot(File dir){
  boolean changed=deselected.remove(dir);
  for (  File root : roots) {
    if (FileUtils.isAncestor(root,dir)) {
      if (root.equals(dir)) {
        if (changed) {
          directoryTreeModel.valueForPathChanged(getTreePath(dir),null);
        }
        return changed;
      }
      removeFromPath(dir);
      TreePath path=getTreePath(dir);
      directoryTree.scrollPathToVisible(path);
      return changed;
    }
 else     if (FileUtils.isAncestor(dir,root)) {
      removeRoot(root);
      addDirToTree(dir);
      setExpanded(root);
      setExpanded(root.getParentFile());
      return true;
    }
  }
  addDirToTree(dir);
  setRootExpanded();
  return true;
}

public boolean addRoot ( File dir ) { boolean changed = deselected . remove ( dir ) ; for ( File root : roots ) { if ( FileUtils . isAncestor ( root , dir ) ) { if ( root . equals ( dir ) ) { if ( changed ) { directoryTreeModel . valueForPathChanged ( getTreePath ( dir ) , null ) ; } return changed ; } removeFromPath ( dir ) ; TreePath path = getTreePath ( dir ) ; directoryTree . scrollPathToVisible ( path ) ; return changed ; } else if ( FileUtils . isAncestor ( dir , root ) ) { removeRoot ( root ) ; addDirToTree ( dir ) ; setExpanded ( root ) ; setExpanded ( root . getParentFile ( ) ) ; return true ; } } addDirToTree ( dir ) ; setRootExpanded ( ) ; return true ; }
adds a root to the tree if it ' s not already in there .
