I'm trying to create a Tic-Tac-Toe-like program with a board size that users can select. I can't figure out how to adjust the size of a gridpane in the code. My only lead was using ColumnConstraints and RowContraints, but I have two issues:
- When adding a row or column, it won't add multiple rows and columns in a for loop.
- I can't figure out how to resize both the grid and the window so that larger version of the grid is usable.
Code for function here:
public void changeGameBoard(ActionEvent event) {
if (boardNumber > 2) {
boardNumber = 50;
sizeLabel.setText("Set at :" + boardNumber);
ColumnConstraints column1 = new ColumnConstraints();
RowConstraints row1 = new RowConstraints();
for (int i = 0; i < boardNumber; i++) {
column1.setPrefWidth(100);
row1.setPrefHeight((100));
}
gameBoard.getColumnConstraints().add(column1);
gameBoard.getRowConstraints().add(row1);
gameBoard.setMinSize(500,500);
}
}
I've tried playing with padding in SceneBuilder and with setMinSize
of my gridpane (the gameBoard object). I can't find any resources to help though. I'm also working with IntelliJ.