My target is to build a Window in JavaFX where there will be 24 buttons, such way that:
- The buttons should be placed in 4x6 grid (meaning 4 columns, 6 rows)
- Edit the grid and buttons in a way that allows the grid to fill the whole window (even when resizing)
The problem I've right now is regarding the button size, I was able to increase the button size using setMinHeight and setMaxHeight However It's not responsive incase of window size change.
My code-
private Button getSOSButton(){
//create button
Button b = new Button();
b.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE)
return b;
};
I've tried b.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE) inside of the loop but it's not working.
int i=0;
int j=0;
GridPane gridPane = new GridPane();
for(i=0;i<6;i++) {
for (j = 0; j < 4; j++) {
gridPane.add(getSOSButton(), i, j, 1, 1);
}
}
gridPane.setPadding(new Insets(25,0,0,0));
gridPane.setAlignment(Pos.CENTER);
StackPane layout = new StackPane();
layout.getChildren().addAll(hbox,gridPane);
Scene scene = new Scene(layout, 600, 800);
stage.setScene(scene);
stage.show();