Java JTree Model setTreePaths(TreeModel in, Object root, TreePath[] items, Object[] path, int index)

Here you can find the source of setTreePaths(TreeModel in, Object root, TreePath[] items, Object[] path, int index)

Description

Fill in an array of TreePaths for the entire tree

License

Apache License

Parameter

Parameter Description
in - the tree model

Return

- index of first unused access

Declaration

protected static int setTreePaths(TreeModel in, Object root, TreePath[] items, Object[] path, int index) 

Method Source Code

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

import javax.swing.tree.*;

public class Main {
    /**/*from   w  ww  .j  a  v a2  s .co  m*/
    Fill in an array of TreePaths for the entire tree
    @param in - the tree model
    @parem root - starting node - non-null
    @parem items - array of Objects
    @parem index - index on entry
    @return - index of first unused access
    */
    protected static int setTreePaths(TreeModel in, Object root, TreePath[] items, Object[] path, int index) {
        // build a new path
        Object[] newPath = new Object[path.length + 1];
        System.arraycopy(path, 0, newPath, 0, path.length);
        newPath[path.length] = root;

        items[index++] = new TreePath(newPath);

        for (int i = 0; i < in.getChildCount(root); i++) {
            index = setTreePaths(in, in.getChild(root, i), items, newPath, index);
        }
        return (index);
    }
}

Related

  1. nodesChanged(DefaultTreeModel rightTreeModel)
  2. redrawAllTreeCells(DefaultTreeModel treeModel)
  3. redrawAllTreeCellsRec(DefaultTreeModel treeModel, TreeNode parent)
  4. searchPath(TreeModel model, TreePath oldPath)
  5. setTreeObjects(TreeModel in, Object root, Object[] items, int index)
  6. showTreeComponent(String blank, TreeModel model, Object node)