Java JComponent Container getRootContainer(Component c)

Here you can find the source of getRootContainer(Component c)

Description

get Root Container

License

GNU General Public License

Declaration

public static Container getRootContainer(Component c) 

Method Source Code

//package com.java2s;
/*// w  w w  . j a  va 2  s.c om
 * Copyright (C) 2015  University of Oregon
 *
 * You may distribute under the terms of either the GNU General Public
 * License or the Apache License, as specified in the LICENSE file.
 *
 * For more information, see the LICENSE file.
 */

import java.awt.*;

import javax.swing.*;

public class Main {
    public static Container getRootContainer(Component c) {
        if (c == null) {
            return null;
        }
        Container parent = c.getParent();
        while ((parent != null) && !(parent instanceof JPopupMenu)
                && !(parent instanceof JInternalFrame)
                && !(parent instanceof Window)
                && (parent.getParent() != null)) {
            parent = parent.getParent();
        }
        return parent;
    }
}

Related

  1. getPanelFor(JComponent comp1, JComponent comp2)
  2. getParent(JComponent parent, final int... path)
  3. getParentPanel(JComponent jc)
  4. getRoot(Component comp)
  5. getRoot(JComponent pchildComponent)
  6. getRootContainer(Component c)
  7. getRootContainer(Component c)
  8. getRootContainer(Component c)
  9. getRootPane(Component cmp)