Java examples for Swing:JFrame
find Parent Frame
//package com.java2s; import java.awt.Component; import java.awt.Container; import java.awt.Frame; public class Main { public static Frame findParentFrame(Component component) { if (component == null) { throw new NullPointerException("component == null"); }/*w w w .j a va 2s. com*/ Container parent = component.getParent(); while (parent != null) { if ((parent instanceof Frame)) { return (Frame) parent; } parent = parent.getParent(); } return null; } }