Reputation: 2288
I have a custom component that extends CubicCurve. It is the third child of an AnchorPane;
Scene
AnchorPane
BorderPane
Circle
CubicCurve
When I call anchorpane.getChildren().remove(cubic_curve)
it loses its functionality (the start and end points are bound to a moveable node -- these are not bound anymore), however I can still see it.
Is there a proper way to 'delete' the shape? Everything I've found just points me to removing the child, however this doesn't work for me.
Thanks in advance.
Upvotes: 1
Views: 441
Reputation: 2288
Fixed!
I was calling getChildren().remove(cubic_curve)
within an .setOnMouseDragReleased()
handler. When I put it within a .setOnMouseReleased()
handler it worked perfectly.
I was trying to connect two nodes with a cubic curve by dragging and dropping. The onDragRelease
handler would be called by the node that is dropped upon -- the curve that it was referencing was not the correct one. By moving it to onMouseReleased
, the handler references the first node that then references the correct curve.
Hope that makes sense!
Upvotes: 1