Java JComponent Container getParentPanel(JComponent jc)

Here you can find the source of getParentPanel(JComponent jc)

Description

go to parent that is not a scroll pane

License

Apache License

Parameter

Parameter Description
jc a parameter

Declaration

public static Container getParentPanel(JComponent jc) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import javax.swing.*;
import java.awt.*;

public class Main {
    /**/*from   w  w  w .  j  a  v  a2 s  .c o m*/
     * go to parent that is not a scroll pane
     * @param jc
     * @return
     */
    public static Container getParentPanel(JComponent jc) {
        Container parent = jc.getParent();
        while (parent != null) {
            if (parent instanceof JPanel)
                return parent;
            if (parent instanceof JFrame)
                return parent;
            if (parent instanceof JDialog)
                return parent;
            if (parent instanceof JRootPane)
                return parent;
            parent = parent.getParent();
        }
        return null;
    }
}

Related

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