When I want to get the height of a Borderpane in an Anchorpane it always returns 0.0
I tried:
a field : private double height;
a method:
public void setHeight() {
height = borderPane.localToScene(borderPane.getBoundsInLocal()).getHeight();
}
and a listener in the constructor:
borderPane.heightProperty().addListener(ob -> setHeight());
I need it for the method:
public double getMiddenY(){
return y + height/2;
}
If I debug, the field height
changes correctly but at the end it's always 0.0
How can I fix this problem?