javafx-2gridpane

Javafx 2 : How do I delete a row or column in Gridpane


If I want to add a row of text fields programatically in JavaFx, i can simply use the gridpane add method

This adds a set of text fields to row 1.

for (int i = 0; i < Fields.size(); i++) {
   gridpane.add(new TextField(), i, 1);
}

Similarly, How do I delete a row?. I dont find a suitable method to delete a row/column conveeniently in JavaFX.


Solution

  • There's no directly equivalent method. To remove nodes, just use gridpane.getChildren().remove(...); or gridpane.getChildren().removeAll(...); and pass in the nodes you want to remove from the pane.