Here you can find the source of getOutermostRootPane(Component c)
public static JRootPane getOutermostRootPane(Component c)
//package com.java2s; //License from project: Open Source License import java.awt.Component; import javax.swing.JApplet; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JRootPane; import javax.swing.JWindow; import javax.swing.RootPaneContainer; import javax.swing.SwingUtilities; public class Main { public static JRootPane getOutermostRootPane(Component c) /* */{//from www .ja v a 2 s. c o m /* 3359 */if (((c instanceof RootPaneContainer)) && (c.getParent() == null)) { /* 3360 */return ((RootPaneContainer) c).getRootPane(); /* */} /* */ /* 3363 */for (; c != null; c = SwingUtilities.getRootPane(c)) { /* 3364 */if ((c instanceof JRootPane)) { /* 3365 */JRootPane lastRootPane = (JRootPane) c; /* 3366 */if (c.getParent().getParent() == null) { /* 3367 */return lastRootPane; /* */} /* 3369 */if (((c.getParent() instanceof JDialog)) || ((c.getParent() instanceof JWindow)) || ((c.getParent() instanceof JFrame)) || ((c.getParent() instanceof JApplet))) /* */{ /* 3371 */return lastRootPane; /* */} /* 3373 */c = c.getParent().getParent(); /* */} /* */} /* 3376 */return null; /* */} }