Reputation: 10859
as the title inquires is it possible?
eg. suppose i have a custom class that extends Shape
private class CR extends Rectangle{
public CR(){}
}
CR cr = new CR(); //normal rectangle
Pane pane = new Pane();// my node who extends region
pane.setPrefSize(100.0,100.0);
pane.setShape(cr); // here is what i am interested in
i want to know when cr
has been set to a Node
, is there any bindings, or any way i can be notified?
to summarise i have two questions
is there a way to detect either with bindings or some logic when your custom Shape
class is being set to a Region
. ?
can i get a reference to the Node
/Region
/Parent
?
Edit:
i am not suppose/ i do not have - access to the pane or Node that is going to set its shape as the custom shape -(implementing my Shape), something like my class is a library/wrapper.
also my custom Shape
is not extending Rectangle
but just for sample sake but i am extending Path
with extends Shape
to draw a complex Shape
if its possible i will put a bounty of 300 as gift
Upvotes: 1
Views: 575
Reputation: 209330
I'm not entirely clear what you're asking, but does:
cr.parentProperty().addListener((obs, oldParent, newParent) -> {
System.out.println("Parent changed from "+oldParent+" to "+newParent);
if (newParent != null) {
// do whatever you need here...
}
});
do what you need?
Upvotes: 1