I know this has already been answered, but I felt that you deserve a look at how GridLayout works. First http://java.sun.com/docs/books/tutorial/uiswing/layout/gridbag.html and http://www.cs.ubc.ca/local/computing/software/jdk-1.5.0/docs /api/java/awt/GridBagConstraints.html help to decrypt long and cryptic looking method signatures.
There are three main parts of this example for monopolies. There is a layout setting, adding a Large middle part in the form of JPanels and adding external squares in the form of JPanels.
public class GridBagLayoutExample extends JFrame { public static void main(String[] args) { new GridBagLayoutExample().setVisible(true); } public GridBagLayoutExample() { try { //Setup the Layout setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); GridBagLayout thisLayout = new GridBagLayout(); thisLayout.rowWeights = new double[] { 0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2 }; thisLayout.columnWeights = new double[] { 0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2 }; getContentPane().setLayout(thisLayout); //Default Grid values int gridX = 0; int gridY = 0; //Add Panels for Each of the four sides for (int j = 0; j < 4; j++) { for (int i = 0; i < 13; i++) { JPanel tempPanel = new JPanel(); switch(j) { case 0://Top Spaces gridX = i; gridY = 0; break; case 1://Left Spaces gridX = 0; gridY = i; break; case 2://Right Spaces gridX = 12; gridY = i; break; case 3://Bottom Spaces gridX = i; gridY = 12; break; } getContentPane().add(tempPanel, new GridBagConstraints(gridX,// XGridSpot gridY,// YGridSpot 1,// XGridSpaces 1,// YGridSpaces 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,//Fill new Insets(0, 0, 0, 0), 0, 0)); tempPanel.setBorder(BorderFactory .createLineBorder(Color.BLACK)); } } {// Main Inner Area Notice Starts at (1,1) and takes up 11x11 JPanel innerPanel = new JPanel(); getContentPane().add( innerPanel, new GridBagConstraints(1, 1, 11, 11, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); } pack(); setSize(260, 260); } catch (Exception e) { e.printStackTrace(); } } }
Here, if you add a structure to hold the panels, then you can add buttons and everything you want for each of the panels. Instead of panels, buttons will also work. This should compile with the desired import, so compile it and try.