只需从GridPane
的子级中找到最大行索引:
GridPane gridPane = ...
int maxIndex = gridPane.getChildren().stream().mapToInt(n -> {
Integer row = GridPane.getRowIndex(n);
Integer rowSpan = GridPane.getRowSpan(n);
// default values are 0 / 1 respecively
return (row == null ? 0 : row) + (rowSpan == null ? 0 : rowSpan - 1);
}).max().orElse(-1);
// add nodes after last row
gridPane.addRow(maxIndex+1, node1, node2, ...);