I have a question which I think is based on my poor conceptual understanding of OOP/programming generally, but it has come up, specifically, in a JavaFX scenario.
I want to add a child node to parent node and then update that child, and see the update reflected, without having to remove it and re-add it to the parent node. Is this possible? More specifically, I have a Pane (parent) and an ImageView (child) which I want to add to the parent and then later modify.
Pane pane = new Pane();
ImageView picture = new ImageView("dog.png");
pane.getChildren().add(picture);
//now I'm seeing a picture of a dog in my Pane
picture = new ImageView("cat.png");
//So I've reassigned "picture" but am I still seeing a dog?
pane.getChildren().remove(picture);
pane.getChildren().add(picture);
//Am I seeing a cat now?
My apologies if this is unclear or too basic. I can attempt to clarify if needed. Any help is appreciated.