protected Dimension computeLayoutSize(Container parent, int hp, int vp) {
		if (!validWidths)
			return null;
		Component[] components = parent.getComponents();
		int preferredWidth = 0, preferredHeight = 0;
		widths = new int[COLUMNS];
		heights = new int[components.length / COLUMNS];
		// System.out.println("Grid: " + widths.length + ", " + heights.length);

		int i;
		// Pass One: Compute largest widths and heights.
		for (i=0; i<components.length; i++) {
			int row = i / widthPercentages.length;
			int col = i % widthPercentages.length;
			Component c = components[i];
			Dimension d = c.getPreferredSize();
			widths[col] = Math.max(widths[col], d.width);
			heights[row] = Math.max(heights[row], d.height);
		}

		// Pass two: agregate them.
		for (i=0; i<widths.length; i++)
			preferredWidth += widths[i] + hp;
		for (i=0; i<heights.length; i++)
			preferredHeight += heights[i] + vp;

		// Finally, pass the sums back as the actual size.
		return new Dimension(preferredWidth, preferredHeight);
	}