I am trying to programatically insert a single image onto my application. The image does show up in its AnchorPane, but the problem is that the AnchorPane (and therefore the ImageView as well) appears to be stuck to the top left corner of the window.
This AnchorPane is a child of a ScrollPane. I want my image/AnchorPane to be aligned to the top center of the ScrollPane, not the top left. Is dynamic centering of an AnchorPane possible?
To place the
AnchorPane in the top center of the
AnchorPane anchorPane = new AnchorPane(); ... StackPane stackPane = new StackPane(); stack.getChildren().add(anchorPane); StackPane.setAlignment(anchorPane, Pos.TOP_CENTER);