if (source instanceof JFrame) { source = ((JFrame) source).getContentPane(); } else if (source instanceof JInternalFrame) { source = ((JInternalFrame) source).getContentPane(); } else if (source instanceof JDialog) { source = ((JDialog) source).getContentPane(); } setComponentSize(new Dimension(source.getWidth(), source.getHeight()));
setComponentSize(source.getSize());
    public void componentResized(ComponentEvent e) {        Component source = (Component) e.getSource();        if (source instanceof JFrame) {            source = ((JFrame) source).getContentPane();        } else if (source instanceof JInternalFrame) {            source = ((JInternalFrame) source).getContentPane();        } else if (source instanceof JDialog) {            source = ((JDialog) source).getContentPane();        }        setComponentSize(new Dimension(source.getWidth(), source.getHeight()));        Iterator it = iterator();        while (it.hasNext()) {            ((ComponentListener) it.next()).componentResized(e);        }    }