Here you can find the source of getRootFrame(JComponent component)
public static Frame getRootFrame(JComponent component)
//package com.java2s; //License from project: Open Source License import java.awt.Component; import java.awt.Frame; import javax.swing.JComponent; public class Main { public static Frame getRootFrame(JComponent component) { Component c = component;//w ww .ja v a 2 s . com while (!(c instanceof Frame)) c = c.getParent(); return ((Frame) c); } }