Here you can find the source of getRootPaneContainer(Component c)
public static RootPaneContainer getRootPaneContainer(Component c)
//package com.java2s; /******************************************************************************* * Copyright (c) 2016 Weasis Team and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/*from w ww . j a v a 2 s . c om*/ * Nicolas Roduit - initial API and implementation *******************************************************************************/ import java.awt.Component; import java.awt.Container; import javax.swing.RootPaneContainer; public class Main { public static RootPaneContainer getRootPaneContainer(Component c) { if (c instanceof RootPaneContainer) { return (RootPaneContainer) c; } for (Container p = c.getParent(); p != null; p = p.getParent()) { if (p instanceof RootPaneContainer) { return (RootPaneContainer) p; } } return null; } }