Java Utililty Methods JTree Path

List of utility methods to do JTree Path

Description

The list of methods to do JTree Path are organized into topic(s).

Method

voidselectCategoryTreePath(JTree tree, TreePath treePath)
select Category Tree Path
tree.expandPath(treePath);
tree.scrollPathToVisible(treePath);
tree.getSelectionModel().setSelectionPath(treePath);
voidsetTreeState(@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);
StringtreeStringFromTreePath(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();