I have a problem getting the Column index working in JavaFX's GridPane.
I am setting up the grid in two phases. The first method distributes a few buttons in a 6x6 grid:
Button actualButton = new Button(ge.toString());
actualButton.getStyleClass().add("button");
rootNode.add(actualButton, gf.getX(), gf.getY());
where gf.getX()
and gf.getY()
are randomized numbers between 1 and 6 (making sure that no two buttons are put in the same cell.
This part works as expected. The problem is with the second part, when I want to put a Label below the 6x6
grid (ideally with a colspan of 6). No matter how I try, the Label will open a brand new column and push everything one column to the right. It is interesting, because I can set the row index, but not the column index. It also won't react to colspan.
This is the code I'm using, although I have tried various ways:
emptyFieldCounter = new Label("Number of empty fields: " + emptyFields.size());
rootNode.add(emptyFieldCounter,1,7,6,1);
I have tried to change the first int (that is supposedly the column index) to every possible value I could think of - nothing changes. If I change the second int, it will move to a different row, but remain in the same column.
here's a screenshot with 7 as the second int:
and one after changing the 2nd int after changing the col index and row index values to:
rootNode.add(emptyFieldCounter,3,3,6,1);
any hint would be very much appreciated. cheers, Zsolt