Here you can find the source of getParentFrame(Component parent)
public static Frame getParentFrame(Component parent)
//package com.java2s; import java.awt.Component; import java.awt.Frame; import java.awt.Window; import javax.swing.SwingUtilities; public class Main { public static Frame getParentFrame(Component parent) { if (parent instanceof Frame) { return (Frame) parent; }//from w w w . jav a 2 s . co m Window window = SwingUtilities.windowForComponent(parent); return (window instanceof Frame ? (Frame) window : null); } }