/**
 *
 */
package com.github.apixandru.games.rummikub.ui;

import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Insets;

import javax.swing.JButton;
import javax.swing.JPanel;

/**
 * @author Alexandru-Constantin Bledea
 * @since Oct 12, 2015
 */
public final class ScalingGridPanel extends JPanel {


	/**
	 * @param rows
	 * @param cols
	 * @param childW
	 * @param childH
	 */
	public ScalingGridPanel(final int rows, final int cols, final int childW, final int childH) {
		super(new GridLayout(rows, cols));

		final Insets buttonMargin = new Insets(0, 0, 0, 0);
		for (int ii = 0; ii < rows; ii++) {
			for (int jj = 0; jj < cols; jj++) {
				final JButton b = new JButton();
				b.setMargin(buttonMargin);
				b.setPreferredSize(new Dimension(childW, childH));
				add(b);
			}
		}

	}

}

@@ -313,17 +313,16 @@
 anel %7B%0A%0A
-%0A
 %09/**%0A%09 *
@@ -524,16 +524,102 @@
 ols));%0A%0A
+%09%09final Dimension computeDimensions = computeDimensions(rows, cols, childW, childH);%0A%0A
 %09%09final 
@@ -890,10 +890,328 @@
 %09%7D%0A%0A%09%7D%0A%0A
+%09/**%0A%09 * @param rows%0A%09 * @param cols%0A%09 * @param childW%0A%09 * @param childH%0A%09 * @return%0A%09 */%0A%09private static Dimension computeDimensions(final int rows, final int cols, final int childW, final int childH) %7B%0A%09%09final int width = cols * childW;%0A%09%09final int height = rows * childH;%0A%09%09return new Dimension(width, height);%0A%09%7D%0A%0A
 %7D%0A

add ratio computation