The java controller
public class MainContentController implements Initializable {
@FXML private ScrollPane scrollPane;
public void initialize(URL arg0, ResourceBundle arg1) {
Random r = new Random();
JFXMasonryPane masonryPane = new JFXMasonryPane();
scrollPane.setContent(masonryPane);
scrollPane.setFitToWidth(true);
for (int i = 0; i < 6000; i++) {
Label lbl = new Label(String.valueOf(i));
lbl.setAlignment(Pos.CENTER);
lbl.setPrefSize(r.nextInt(200), r.nextInt(200));
lbl.setStyle("-fx-background-color:rgb(" + r.nextInt(255) + "," + r.nextInt(255) + "," + r.nextInt(255) + ");");
masonryPane.getChildren().add(lbl);
}
}
}
And the FXML
<GridPane xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainContentController">
<rowConstraints>
<RowConstraints percentHeight="20.0" />
<RowConstraints percentHeight="20.0" />
<RowConstraints percentHeight="20.0" />
<RowConstraints percentHeight="20.0" />
<RowConstraints percentHeight="20.0" />
</rowConstraints>
<columnConstraints>
<ColumnConstraints percentWidth="25.0" />
<ColumnConstraints percentWidth="25.0" />
<ColumnConstraints percentWidth="25.0" />
<ColumnConstraints percentWidth="25.0" />
</columnConstraints>
<children>
<ScrollPane fx:id="scrollPane" GridPane.columnSpan="4" GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.rowSpan="3" GridPane.valignment="CENTER"/>
</children>
</GridPane>
Tried to use the simplest example I can to show what I mean. When you execute this code, it generates 6000 randomly sized/colored blocks like it's supposed to. However, the amount possible to see depends on the width of your window, and it adjusts as you change it. Theoretically, this should display all 6000 blocks and you just have to scroll farther down if your window is narrower, which is my intent/goal. However, at some seemingly uneventful height it just cuts off anything that would be below it. I cannot find any setting or method that has had any effect on this.
Using JFXMasonryPane by JFoenix. However, I'm not sure if this is an issue with their library or with my utilization of ScrollPane.