Java JComponent Container findRootPaneContainer(final Component source)

Here you can find the source of findRootPaneContainer(final Component source)

Description

Find the root pane container in the current hierarchy.

License

Open Source License

Parameter

Parameter Description
source Component to start with.

Return

Root pane container or NULL if it cannot be found.

Declaration

public static RootPaneContainer findRootPaneContainer(final Component source) 

Method Source Code

//package com.java2s;
/**//from   w ww  .  ja v  a2s  .c  o  m
 * Copyright (C) 2009 Future Invent Informationsmanagement GmbH. All rights
 * reserved. <http://www.fuin.org/>
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 3 of the License, or (at your option) any
 * later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library. If not, see <http://www.gnu.org/licenses/>.
 */

import java.awt.Component;

import javax.swing.RootPaneContainer;

public class Main {
    /**
     * Find the root pane container in the current hierarchy.
     * 
     * @param source
     *            Component to start with.
     * 
     * @return Root pane container or NULL if it cannot be found.
     */
    public static RootPaneContainer findRootPaneContainer(final Component source) {
        Component comp = source;
        while ((comp != null) && !(comp instanceof RootPaneContainer)) {
            comp = comp.getParent();
        }
        if (comp instanceof RootPaneContainer) {
            return (RootPaneContainer) comp;
        }
        return null;
    }
}

Related

  1. checkComponents(final Component _rootComponent, final String _print, final int _currentColumn, final int _currentRow)
  2. findMainRootPane(Component component)
  3. findRootPane(Component component)
  4. findRootPaneContainer(Component c)
  5. findRootPaneContainer(Component root)
  6. getActiveRectangle(JComponent c)
  7. getAllJComponents(Container container, Collection collection)
  8. getAncestorOfType(JComponent component, Class type)
  9. getAncestorsOfClass(JComponent start, Class theClass)