Hey programming student here.
I have a JavaFX application. I have a pane, and I want to remove all rectangles from it. Here is the code:
public Pane yard = new Pane();
...
for(int i = 0; i < yard.getChildren().size(); i++)
{
if(yard.getChildren().get(i) instanceof Rectangle)
{
yard.getChildren().remove(i);
}
}
This works fine, sometimes. Other times it simply fails to remove anything. Thank you for your help.