panel.setSize(dim);
if (dim != null) { panel.setSize(dim); }
    public void layout(Graphics2D g2, Dimension dim) {        this.dim = dim;        panel.setSize(dim);        panel.doActualLayout(g2);    }