How to hide full screen button of Mac OS window (i

2019-09-02 20:54发布

Every window title bar of Mac OS has a full screen button at the top-right corner.Is there any way to hide this default full screen button of Mac OS in JavaFX?

enter image description here

Here is my code snippet:

    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条回答
Rolldiameter
2楼-- · 2019-09-02 21:23

At least for the new dialog API it is sufficient have an owning Window with modality set to APPLICATION_MODAL (default):

Alert alert = new Alert();
alert.initOwner(mainStage);
查看更多
Rolldiameter
3楼-- · 2019-09-02 21:38

One way to do it would be to set the StageStyle to StageStyle.UTILITY

messageBoxStage.initStyle(StageStyle.UTILITY);
查看更多
登录 后发表回答