java如何使弹出窗口居中?
所以我使用jfoenix JFXPopup组件作为我的弹出窗口。最终得到弹出窗口显示后。我意识到弹出窗口是相对于您传递的所有者节点显示的。我的问题是,有没有办法显示与场景相关的弹出窗口,以便将其居中
不幸的是,您不能将弹出窗口置于所有者节点的中心,您只能将其上下或左右移动
Popup relative to the search textfield in the middle of the application
//Current Code
@FXML
protected void handleLoginButton(ActionEvent event) {
System.out.println("Popup BUtton clicked");
if (!loginPopup.isShowing()) {
System.out.println("Popup is open!");
//loginPopup.show(searchBtn, JFXPopup.PopupVPosition.BOTTOM, JFXPopup.PopupHPosition.LEFT);
loginPopup.show(searchBtn);
}
}
# 1 楼答案
调用
show
时使用场景的根窗格,并计算中心位置请参见here以从控制器访问场景