Java tutorial
//package com.java2s; import java.util.StringTokenizer; import javax.swing.JTree; public class Main { /** * Loads the given expansion state of a JTree, making it expand in the given manner. * * @param tree * The JTree to be expended * @param enumeration * The expansion state for tree as Enumeration<TreePath> */ public static void loadTreeExpansionState(JTree tree, String expansionState, int row) { // if a tree is opened for the first time, its expansionState is null if (expansionState == null) { return; } StringTokenizer stok = new StringTokenizer(expansionState, ","); while (stok.hasMoreTokens()) { int token = row + Integer.parseInt(stok.nextToken()); tree.expandRow(token); } } }