I want to dynamically center a small AnchorPane (containing the image) into a larger AnchorPane as shown below. For now, the small AnchorPane contains only an image but more controls will be added later. Statically, I am doing this by setting the top/botton/right/left Anchors. But At runtime, I want the small AnchorPane to remain vertically and horizontally centered even if the parent size changes.
Dynamically, this can be done changing the top/botton/right/left Anchors when the parent resizes, but can this be done in a simpler way, for example, is possible to set the smaller AnchorPane to be always horizontally and vertically centered?