public Dimension minimumLayoutSize(Container parent) {
		//System.err.println("minimumLayoutSize");
	    synchronized (parent.getTreeLock()) {
		    Insets insets = parent.getInsets();
		    int ncomponents = parent.getComponentCount();
		    int nrows = getRows();
		    int ncols = getColumns();
		    if (nrows > 0) {
		    	ncols = (ncomponents + nrows - 1) / nrows;
		    } 
		    else {
		        nrows = (ncomponents + ncols - 1) / ncols;
		    }
		    int[] w = new int[ncols];
		    int[] h = new int[nrows];
		    for (int i = 0; i < ncomponents; i ++) {
		        int r = i / ncols;
		        int c = i % ncols;
		        Component comp = parent.getComponent(i);
		        Dimension d = comp.getMinimumSize();
		        if (w[c] < d.width) {
		        	w[c] = d.width;
		        }
		        if (h[r] < d.height) {
		        	h[r] = d.height;
		        }
		    }
		    int nw = 0;
		    for (int j = 0; j < ncols; j ++) {
		    	nw += w[j];
		    }
		    int nh = 0;
		    for (int i = 0; i < nrows; i ++) {
		        nh += h[i];
		    }
		    return new Dimension(insets.left + insets.right + nw + (ncols-1)*getHgap(), 
		    		insets.top + insets.bottom + nh + (nrows-1)*getVgap());
	    }
	}