List of utility methods to do JTree Expand
List | getLastExpandedNodes(final JTree tree) get Last Expanded Nodes final List<DefaultMutableTreeNode> nodeList = new ArrayList<DefaultMutableTreeNode>(); final int rowCount = tree.getRowCount(); for (int i = 0; i < rowCount; i++) { final TreePath path = tree.getPathForRow(i); DefaultMutableTreeNode lastPathComponent = null; try { lastPathComponent = (DefaultMutableTreeNode) path.getLastPathComponent(); } catch (final Exception e) { ... |
TreePath[] | getPaths(JTree tree, boolean expanded) Permet de convertir un TreeNode en TreePath[] TreeNode root = (TreeNode) tree.getModel().getRoot(); List<TreePath> list = new ArrayList<>(); getPaths(tree, new TreePath(root), expanded, list); return (TreePath[]) list.toArray(new TreePath[list.size()]); |
Icon | getTreeSelectedExpandedIcon() get Tree Selected Expanded Icon return getTreeExpandedIcon();
|
boolean | isTreePathExpandable(TreeModel treeModel, TreePath treePath) is Tree Path Expandable if (treeModel == null) return false; if (treePath == null) return false; return !treeModel.isLeaf(treePath.getLastPathComponent()) && isTreePathInModel(treeModel, treePath); |
void | makeTreeAutoExpandable(JTree tree) By calling this method, the provided tree will become auto-expandable, i.e. makeTreeAutoExpandable(tree, 1, false); |
boolean | searchUnexpandedPath(JTree tree, TreePath path, int index, TreeNode node, TreePath[] result, boolean compareOnlyLabels) search Unexpanded Path Object[] pathElements = path.getPath(); if (index >= pathElements.length) { return !tree.isExpanded(result[0]); Object elementToSearch = pathElements[index]; Enumeration<?> enumeration = node.children(); while (enumeration.hasMoreElements()) { TreeNode next = (TreeNode) enumeration.nextElement(); ... |
void | setExpandedIcon(JTree tree, Icon icon) Set's the expanded icon to use for the given JTree if that tree's UI delegate extends from BasicTreeUI . ((BasicTreeUI) tree.getUI()).setExpandedIcon(icon); |
void | setExpandedOnEdt(JTree tree, TreePath path, boolean expanded) set Expanded On Edt if (expanded) { expandPathOnEdt(tree, path); } else { collapsePathOnEdt(tree, path); |
void | setExpandedPaths(JTree tree, TreePath[] expandedPaths) Expand all the previously remembered expanded paths. if (expandedPaths == null) { return; for (int i = 0; i < expandedPaths.length; ++i) { TreePath oldPath = expandedPaths[i]; TreePath newPath = searchPath(tree.getModel(), oldPath); if (newPath != null) { tree.expandPath(newPath); ... |
void | setFullyExpandedPath(JTree Target, TreeModel TheModel, Object Node, Vector Path) set Fully Expanded Path if (TheModel.isLeaf(Node) || TheModel.getChildCount(Node) == 0) { Object[] FullPath = new Object[Path.size()]; Path.copyInto(FullPath); Target.expandPath(new TreePath(FullPath)); return; for (int i = 0; i < TheModel.getChildCount(Node); i++) { Object Child = TheModel.getChild(Node, i); ... |