如何隐藏Mac OS窗口的全屏按钮(在JavaFX中)?

时间:2014-01-02 10:17:46

标签: javafx javafx-2 javafx-8

Mac OS的每个窗口标题栏右上角都有一个全屏按钮。有没有办法在JavaFX中隐藏Mac OS的默认全屏按钮?

enter image description here

这是我的代码段:

    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();
        }
    });
}

2 个答案:

答案 0 :(得分:1)

至少对于new dialog API来说,拥有Window且模态设置为APPLICATION_MODAL(默认)就足够了:

Alert alert = new Alert();
alert.initOwner(mainStage);

答案 1 :(得分:0)

一种方法是将StageStyle设置为StageStyle.UTILITY

messageBoxStage.initStyle(StageStyle.UTILITY);