Java JTree Expand setFullyExpandedPath(JTree Target, TreeModel TheModel, Object Node, Vector Path)

Here you can find the source of setFullyExpandedPath(JTree Target, TreeModel TheModel, Object Node, Vector Path)

Description

set Fully Expanded Path

License

Apache License

Declaration

protected static void setFullyExpandedPath(JTree Target, TreeModel TheModel, Object Node, Vector Path) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.*;

import javax.swing.*;

import javax.swing.tree.*;

public class Main {
    protected static void setFullyExpandedPath(JTree Target, TreeModel TheModel, Object Node, Vector Path) {
        if (TheModel.isLeaf(Node) || TheModel.getChildCount(Node) == 0) {
            Object[] FullPath = new Object[Path.size()];
            Path.copyInto(FullPath);
            Target.expandPath(new TreePath(FullPath));
            return;
        }//from  w  w w .java  2  s. c om
        for (int i = 0; i < TheModel.getChildCount(Node); i++) {
            Object Child = TheModel.getChild(Node, i);
            Path.addElement(Child);
            setFullyExpandedPath(Target, TheModel, Child, Path);
            Path.removeElement(Child);
        }
    }
}

Related

  1. makeTreeAutoExpandable(JTree tree)
  2. searchUnexpandedPath(JTree tree, TreePath path, int index, TreeNode node, TreePath[] result, boolean compareOnlyLabels)
  3. setExpandedIcon(JTree tree, Icon icon)
  4. setExpandedOnEdt(JTree tree, TreePath path, boolean expanded)
  5. setExpandedPaths(JTree tree, TreePath[] expandedPaths)