diff --git a/src/de/itsblue/ConnectFour/GameBoard.java b/src/de/itsblue/ConnectFour/GameBoard.java index adef831..fc02c4b 100644 --- a/src/de/itsblue/ConnectFour/GameBoard.java +++ b/src/de/itsblue/ConnectFour/GameBoard.java @@ -11,10 +11,10 @@ public class GameBoard extends JPanel { */ private static final long serialVersionUID = 1L; - public int r = 6; public int c = 7; - GridLayout BoardLayout = new GridLayout(7, 6); + GridLayout BoardLayout = new GridLayout(c,r+1); + JPanel[][] BoardContainers = new JPanel[c][r]; int[][] GameBoard = new int[c][r]; int[] filllevel = new int[r]; int p; // Player @@ -23,6 +23,7 @@ public class GameBoard extends JPanel { public void addComponentsToPane() { final JPanel field = this; + field.setLayout(BoardLayout); // Set up components preferred size @@ -36,19 +37,21 @@ public class GameBoard extends JPanel { for (int i = 1; i < 8; i++) { field.add(new JButton("" + i)); } - for (int i = 1; i < c; i++) { + + for (int i = 0; i < r; i++) { // // first column - field.add(new Plate(Plate.PlateType.O)); - for (int j = 0; j < r; j++) { + + for (int j = 0; j < c; j++) { // field.add(new Plate(Plate.PlateType.X)); - if (GameBoard[i][j] == 0) // FIXME - field.add(new Plate(Plate.PlateType.X)); + this.BoardContainers[j][i] = new JPanel(new GridBagLayout()); + this.BoardContainers[j][i].setPreferredSize(new Dimension(20, 20)); - else if (GameBoard[i][j] == 1) - field.add(new Plate(Plate.PlateType.X)); + if(j == 0) + this.BoardContainers[j][i].add(new Plate(Plate.PlateType.O)); else - field.add(new Plate(Plate.PlateType.O)); + this.BoardContainers[j][i].add(new Plate(Plate.PlateType.X)); + this.add(this.BoardContainers[j][i]); } }