Here you can find the source of getJFrame(Component cmp)
public static JFrame getJFrame(Component cmp)
//package com.java2s; //License from project: Open Source License import java.awt.Component; import javax.swing.JFrame; import javax.swing.SwingUtilities; public class Main { /**/*from w w w . j a va2 s . c om*/ * Gets the parent JFrame of the component. */ public static JFrame getJFrame(Component cmp) { return (JFrame) SwingUtilities.getWindowAncestor(cmp); } }