Here you can find the source of buildParentFrame(Object inp)
public static Frame buildParentFrame(Object inp)
//package com.java2s; //License from project: Apache License import javax.swing.*; import java.awt.*; public class Main { public static Frame buildParentFrame(Object inp) { if (inp == null) return null; if (inp instanceof Frame) return (Frame) inp; if (inp instanceof Component) { Component root = SwingUtilities.getRoot((Component) inp); if (root != inp) return buildParentFrame(root); if (root.getParent() != root) return buildParentFrame(root.getParent()); }//from ww w . j a v a 2 s. co m return null; } }