Java JTree Collapse setCollapsedIcon(JTree tree, Icon icon)

Here you can find the source of setCollapsedIcon(JTree tree, Icon icon)

Description

Set's the collapsed icon to use for the given JTree if that tree's UI delegate exetends from BasicTreeUI .

License

Open Source License

Parameter

Parameter Description
tree the tree to set the collapsed icon for.
icon the new collapsed icon to use.

Declaration

public static void setCollapsedIcon(JTree tree, Icon icon) 

Method Source Code

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

import javax.swing.Icon;
import javax.swing.JTree;

import javax.swing.plaf.basic.BasicTreeUI;

public class Main {
    /**//from  ww  w. j  a v a2  s .co  m
     * Set's the collapsed icon to use for the given {@link JTree} if that
     * tree's UI delegate exetends from {@link BasicTreeUI}. If the given tree's
     * UI delegate does not extend from {@code BasicTreeUI} then the given
     * tree will not be changed.
     *
     * @param tree the tree to set the collapsed icon for.
     * @param icon the new collapsed icon to use.
     * @see BasicTreeUI#setCollapsedIcon(javax.swing.Icon)
     */
    public static void setCollapsedIcon(JTree tree, Icon icon) {
        if (tree.getUI() instanceof BasicTreeUI) {
            ((BasicTreeUI) tree.getUI()).setCollapsedIcon(icon);
        }
    }
}

Related

  1. collapseAllRows(JTree tree)
  2. collapseTree(JTree tree)
  3. collapseTree(JTree tree)
  4. fullSelectionCollapse(JTree tree)
  5. getTreeSelectedCollapsedIcon()