/** Constructs the tree path for a directory. */
 private TreePath getTreePath(File dir) {
   LinkedList<File> files = new LinkedList<File>();
   files.add(dir);
   File parent = dir.getParentFile();
   while (parent != null && !directoryTreeModel.isSubRoot(dir)) {
     files.addFirst(parent);
     dir = parent;
     parent = parent.getParentFile();
   }
   Object[] path = new Object[files.size() + 1];
   path[0] = directoryTreeModel.getRoot();
   System.arraycopy(files.toArray(), 0, path, 1, path.length - 1);
   return new TreePath(path);
 }
 /** Expand the visible or invisible root node. */
 public void setRootExpanded() {
   directoryTree.expandPath(new TreePath(directoryTreeModel.getRoot()));
 }