Expands all nodes in the specified tree. - Java Swing

Java examples for Swing:JTree

Description

Expands all nodes in the specified tree.

Demo Code

/*//from w ww .  ja v  a  2  s . c  o m
 * 09/08/2005
 *
 * UIUtil.java - Utility methods for org.fife.ui classes.
 * Copyright (C) 2005 Robert Futrell
 * http://fifesoft.com/rtext
 * Licensed under a modified BSD license.
 * See the included license file for details.
 */
//package com.java2s;

import javax.swing.JTree;

public class Main {
    /**
     * Expands all nodes in the specified tree.
     *
     * @param tree The tree.
     */
    public static void expandAllNodes(final JTree tree) {
        // Do separately for nested panels.
        int j = 0;
        while (j < tree.getRowCount()) {
            tree.expandRow(j++);
        }
    }
}

Related Tutorials