Mac OS的每个窗口标题栏右上角都有一个全屏按钮。有没有办法在JavaFX中隐藏Mac OS的默认全屏按钮?
这是我的代码段:
public static void launchOkMessageBox(){
pane = new VBox();
scene = new Scene(pane,150,60, Color.GHOSTWHITE);
Label label = new Label("Hello Word");
Button okButton = new Button("Ok");
pane.getChildren().add(label);
pane.getChildren().add(okButton);
pane.setAlignment(Pos.CENTER);
pane.setSpacing(10);
messageBoxStage.setScene(scene);
messageBoxStage.setResizable(false);
messageBoxStage.sizeToScene();
messageBoxStage.show();
okButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
messageBoxStage.close();
}
});
}
答案 0 :(得分:1)
至少对于new dialog API来说,拥有Window
且模态设置为APPLICATION_MODAL
(默认)就足够了:
Alert alert = new Alert();
alert.initOwner(mainStage);
答案 1 :(得分:0)
一种方法是将StageStyle
设置为StageStyle.UTILITY
messageBoxStage.initStyle(StageStyle.UTILITY);