I use JavaFX with FXML and I want to show some tiles in 1:1 size (squares).
In my initialize method (gluon javafx mobile app) I use the code below to make my tiles quadratic.
The GridPane has vgap and hgap set. So if the code below ran, the tiles are squares, but the gap between the rows is greater than my set number, because the GridPane is now greater than needed, because the tiles where shrunken at runtime. Is there a way to fix the gap size between the rows in any way or to force the GridPane to shrink with the childrens height?
I've tried so many things in the fxml with gaps, alignment, percentWidth etc etc... I hope anyone could help me :)
primary.getChildren().stream().filter(n -> n instanceof GridPane).forEach(g -> ((GridPane) g).getChildren().stream().filter(n -> n instanceof Button).forEach(b -> ((Button) b).maxHeightProperty().bind(((Button) b).widthProperty())));