some changes to the layout

This commit is contained in:
Dorian Zedler 2020-02-12 15:37:51 +01:00
parent 08440f45dd
commit 4b1b5c0f92

View file

@ -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]);
}
}