コード例 #1
0
 /** 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);
 }
コード例 #2
0
 /** Expand the visible or invisible root node. */
 public void setRootExpanded() {
   directoryTree.expandPath(new TreePath(directoryTreeModel.getRoot()));
 }