Java tutorial
//package com.java2s; //License from project: Open Source License import java.awt.Container; import java.awt.Frame; public class Main { public static Frame getParentFrame(Container container) { Container parent = container.getParent(); while ((parent != null) && !(parent instanceof Frame)) { parent = parent.getParent(); } return (Frame) parent; } }