Java tutorial
//package com.java2s; import java.awt.Container; import javax.swing.JFrame; public class Main { public static JFrame getFrame(Container component) { JFrame frame = null; if (component != null) { if (component instanceof JFrame) { frame = (JFrame) component; } else { frame = getFrame(component.getParent()); } } return frame; } }