0
我想编程插入到我的应用程序的单个图像。该图像显示在其AnchorPane中,但问题在于AnchorPane(以及ImageView)似乎卡在窗口的左上角。动态AnchorPane调整
这个AnchorPane是一个ScrollPane的孩子。我希望我的图像/ AnchorPane对齐到ScrollPane的顶部中心,而不是左上角。 AnchorPane的动态集中可能吗?
我想编程插入到我的应用程序的单个图像。该图像显示在其AnchorPane中,但问题在于AnchorPane(以及ImageView)似乎卡在窗口的左上角。动态AnchorPane调整
这个AnchorPane是一个ScrollPane的孩子。我希望我的图像/ AnchorPane对齐到ScrollPane的顶部中心,而不是左上角。 AnchorPane的动态集中可能吗?
要动态地对中AnchorPane,请将其置于StackPane。
要放置AnchorPane
在StackPane
的顶部中心,呼叫
StackPane.setAlignment(node, Pos.TOP_CENTER)
AnchorPane anchorPane = new AnchorPane();
...
StackPane stackPane = new StackPane();
stack.getChildren().add(anchorPane);
StackPane.setAlignment(anchorPane, Pos.TOP_CENTER);