Here you can find the source of getParentFrame(Component component)
public static JFrame getParentFrame(Component component)
//package com.java2s; /*//from w w w . j a v a2s. c o m * codjo.net * * Common Apache License 2.0 */ import java.awt.Component; import java.awt.Container; import javax.swing.JFrame; public class Main { public static JFrame getParentFrame(Component component) { Container container = component.getParent(); if (container instanceof JFrame || container == null) { return (JFrame) container; } else { return getParentFrame(container); } } }