Java JTree findTree(Container container)

Here you can find the source of findTree(Container container)

Description

Traverse a container hierarchy and returns the first JMenuBar it finds.

License

Open Source License

Declaration

static JTree findTree(Container container) 

Method Source Code


//package com.java2s;
// it under the terms of the GNU General Public License as published by

import java.awt.Component;
import java.awt.Container;

import javax.swing.JTree;

public class Main {
    /**/*from w w w  .j av a2  s  .com*/
     * Traverse a container hierarchy and returns the first JMenuBar
     * it finds.
     *
     */
    static JTree findTree(Container container) {
        Component[] components = container.getComponents();

        for (Component component : components) {
            if (component instanceof JTree) {
                return (JTree) component;
            } else if (component instanceof Container) {
                JTree tree = findTree((Container) component);
                if (tree != null) {
                    return tree;
                }
            }
        }
        return null;
    }
}

Related

  1. clearTreeIcon(JTree tree)
  2. correctRowHeight(JTree tree)
  3. disposeExpressionsTree()
  4. enableAutoExpansion(final JTree tree)
  5. findByName(JTree tree, String[] names)
  6. getCurrentWidth(JTree tree, int row)
  7. getExpansionState(JTree tree, int row)
  8. getProjectTree()
  9. getSelectionFromTree(JTree tree)