Java JPanel Child getOutermostContainer(JPanel container)

Here you can find the source of getOutermostContainer(JPanel container)

Description

get Outermost Container

License

Apache License

Declaration

private static WindowConstants getOutermostContainer(JPanel container) 

Method Source Code


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

import javax.swing.*;

import java.awt.*;

public class Main {
    private static WindowConstants getOutermostContainer(JPanel container) {
        Container pnl = container;
        while (pnl.getParent() != null) {
            if (pnl.getParent() instanceof JInternalFrame) {
                return (JInternalFrame) pnl.getParent();
            }//w  w  w.j  ava 2 s .c o  m
            if (pnl.getParent() instanceof JDialog) {
                return (JDialog) pnl.getParent();
            }
            if (pnl.getParent() instanceof JFrame) {
                return (JFrame) pnl.getParent();
            }
            pnl = pnl.getParent();
        }
        return null;
    }
}

Related

  1. addUIComponent(JPanel jp, JComponent jc, int loc, int type, int[] decart, Insets insets)
  2. addWidth(JPanel panel, int width)
  3. addWithPadding(JPanel parentPanel, JPanel panelToBeAdded)
  4. fillPanel(final JPanel panel, final GridBagConstraints gbc)
  5. fillPanel(JPanel panel, Component... components)
  6. packPanel(JPanel p, int width)
  7. padPanel(Object innerPanel, JPanel outerPanel, int pad)
  8. removeComponentFromPanel(Component removeComponent, JPanel fromPanel)
  9. removePanel(JPanel parent, JPanel panel)