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

2019-09-02 20:53发布

问题:

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?

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

回答1:

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


回答2:

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

messageBoxStage.initStyle(StageStyle.UTILITY);