I Have a gridpane and the number of row may be inderterminate. How add a number row of gridpane ? Or How add at the last of gridpane ?
Thanks.
Simply find the maximum row index from the children of the 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, ...);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments