Here you can find the source of getOutermostContainer(JPanel container)
private static WindowConstants getOutermostContainer(JPanel container)
//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; } }