Java tutorial
//package com.java2s; import java.awt.Component; public class Main { public static Component getRootPane(Component p_component) { Component rootPane = p_component.getParent(); for (; rootPane != null;) { if (rootPane.getParent() == null) { break; } rootPane = rootPane.getParent(); } return rootPane; } }