restore JTree Expansion State - Java Swing

Java examples for Swing:JTree

Description

restore JTree Expansion State

Demo Code


//package com.java2s;
import java.util.StringTokenizer;
import javax.swing.JTree;

public class Main {
    /**/*from  w  w w.  j ava2  s  .com*/
     *
     *
     * @param tree
     * @param row
     * @param expansionState
     */
    public static void restoreExpansionState(JTree tree, int row,
            String expansionState) {
        StringTokenizer stok = new StringTokenizer(expansionState, ",");

        while (stok.hasMoreTokens()) {
            int token = row + Integer.parseInt(stok.nextToken());

            tree.expandRow(token);
        }
    }
}

Related Tutorials