protected Window getParentWindow()
    {
        Container container = getParent();
        while(container != null) {
            if(container instanceof Window)
                return ((Window)(container));
            else if(container instanceof Component)
                container = ((Component)container).getParent();
            else
                break;
        }
        return null;
    }