if (n == 0) { node.getInternalDesktop().setPreferredSize( node.getTitleMinimumSize()); node.setVisible(true); return; }
    public void visit(ImageSet node)    {        //First find out the max dim among children.        Dimension maxDim = maxChildDim(node);                //Then figure out the number of columns, which is the same as the        //number of rows.        int n = node.getChildrenDisplay().size();        n = (int) Math.floor(Math.sqrt(n)) + 1;  //See note.                //Finally do layout.        Dimension d;        Iterator children = node.getChildrenDisplay().iterator();        ImageDisplay child;        try {            for (int i = 0; i < n; ++i) {                for (int j = 0; j < n; ++j) {                    if (!children.hasNext()) //Done, less than n^2 children.                        return;  //Go to finally.                    child = (ImageDisplay) children.next();                    d = child.getPreferredSize();                    child.setBounds(i*maxDim.width, j*maxDim.height,                                    d.width, d.height);                    child.setVisible(true);                }            }            } finally {            Rectangle bounds = node.getContentsBounds();            d = bounds.getSize();            node.getInternalDesktop().setPreferredSize(d);            node.setVisible(true);        }    }