public static void removeRowsFromGridPane(GridPane gridPane, int fromGridRow, int toGridRow) { Set<Node> nodes = new CopyOnWriteArraySet<>(gridPane.getChildren()); nodes .stream() .filter(e -> GridPane.getRowIndex(e) >= fromGridRow && GridPane.getRowIndex(e) <= toGridRow) .forEach(e -> gridPane.getChildren().remove(e)); }