Is there a way to make it so the objects/cells of a GridPane are made to fit the parent (TabPane in this instance)? I have been trying this using buttons inside of the GridPane for the past for hours and haven't been able to find a solution.
Here is what I've been trying:
GridPane gPane = new GridPane();
double size = Math.sqrt((tabPane.getTabs().get(0).getContent().getLayoutBounds().getHeight() * tabPane.getTabs().get(0).getContent().getLayoutBounds().getWidth()) / (rows * columns));
for (int i = 0; i < height; i++)
for (int j = 0; j < width; j++) {
array[i][j] = new Button();
array[i][j].setPrefWidth(size);
array[i][j].setPrefHeight(size);
gPane.add(array[i][j], i, j);
}
When I run this, the size of the cells either don't match the size, or when they do, they do not fit the screen as they should.