I need to change the anchorpoint for a label in JavaFX. I describe the anchor as the point that is picked to translate the underlying node. As default the anchorpoint seems to be the upper left edge.
I tried to solve the problem with an additional translation as described below:
double x_relocate = label.getBoundsInParent().getWidth();
label.setTranslateX(label.getTranslateX() - x_relocate);
double y_relocate = label.getBoundsInParent().getHeight();
label.setTranslateY(des.getTranslateY() + y_relocate);
The code should translate the label so that it acts like the anchorpoint would be in the lower right corner. This does not not work because at the point I do execute the code my bounding box for the label is [minX:0.0, minY:0.0, minZ:0.0, width:-1.0, height:-1.0, depth:0.0, maxX:-1.0, maxY:-1.0, maxZ:0.0].
Does anyone know a solution for this?
EDIT: Added a picture for better unterstanding