/**
     * find Frame/JFrame enclosing a Component/Container/Dialog/Applet... Returns null if can't find one.
     * Useful when you need to pass the enclosing Frame to to a JDialog constructor.
     *
     * @return Frame, will be typically not be a literal Frame, but a
     *         javax.swing.JFrame, sun.applet.AppletViewer, class sun.plugin2.main.client.PluginEmbeddedFrame (For JApplet)
     */
    public static Frame getParentFrame( Component child )
    {
    Container c = child.getParent();
    while ( c != null )
        {
        if ( c instanceof Frame )
            {
            return ( Frame ) c;
            }
        c = c.getParent();
        }
    return null;
    }