List of utility methods to do JTree Path
void | selectCategoryTreePath(JTree tree, TreePath treePath) select Category Tree Path tree.expandPath(treePath); tree.scrollPathToVisible(treePath); tree.getSelectionModel().setSelectionPath(treePath); |
void | setTreeState(@Nonnull final JTree tree, @Nonnull final TreePath path, final boolean recursively, final boolean unfold) set Tree State final Object lastNode = path.getLastPathComponent(); for (int i = 0; i < tree.getModel().getChildCount(lastNode); i++) { final Object child = tree.getModel().getChild(lastNode, i); final TreePath pathToChild = path.pathByAddingChild(child); if (recursively) { setTreeState(tree, pathToChild, recursively, unfold); if (unfold) { tree.expandPath(path); } else { tree.collapsePath(path); |
String | treeStringFromTreePath(TreePath path) tree String From Tree Path StringBuilder db_path = new StringBuilder("BaseX Server"); for (int i = 1; i < path.getPathCount(); i++) { db_path.append("/").append(path.getPathComponent(i).toString()); return db_path.toString(); |