Java JTree Expand setExpandedOnEdt(JTree tree, TreePath path, boolean expanded)

Here you can find the source of setExpandedOnEdt(JTree tree, TreePath path, boolean expanded)

Description

set Expanded On Edt

License

Open Source License

Declaration

public static void setExpandedOnEdt(JTree tree, TreePath path, boolean expanded) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.JTree;
import javax.swing.SwingUtilities;

import javax.swing.tree.TreePath;

public class Main {
    public static void setExpandedOnEdt(JTree tree, TreePath path, boolean expanded) {
        if (expanded) {
            expandPathOnEdt(tree, path);
        } else {//  w ww .  j ava2 s. c o m
            collapsePathOnEdt(tree, path);
        }
    }

    public static void expandPathOnEdt(final JTree tree, final TreePath path) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                tree.expandPath(path);
            }
        });
    }

    public static void collapsePathOnEdt(final JTree tree, final TreePath path) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                tree.collapsePath(path);
            }
        });
    }
}

Related

  1. getTreeSelectedExpandedIcon()
  2. isTreePathExpandable(TreeModel treeModel, TreePath treePath)
  3. makeTreeAutoExpandable(JTree tree)
  4. searchUnexpandedPath(JTree tree, TreePath path, int index, TreeNode node, TreePath[] result, boolean compareOnlyLabels)
  5. setExpandedIcon(JTree tree, Icon icon)
  6. setExpandedPaths(JTree tree, TreePath[] expandedPaths)
  7. setFullyExpandedPath(JTree Target, TreeModel TheModel, Object Node, Vector Path)