Here you can find the source of findJFrame(Component myComponent)
public static JFrame findJFrame(Component myComponent)
//package com.java2s; //License from project: Open Source License import java.awt.Component; import javax.swing.JFrame; public class Main { public static JFrame findJFrame(Component myComponent) { Component currentParent = myComponent; JFrame myFrame = null;//from ww w.j av a 2s.c om while (currentParent != null) { if (currentParent instanceof JFrame) { myFrame = (JFrame) currentParent; break; } currentParent = currentParent.getParent(); } return myFrame; } }