How to hide full screen button of Mac OS window (in JavaFX)?

风流意气都作罢 提交于 2019-12-24 19:28:58

问题


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


来源:https://stackoverflow.com/questions/20880672/how-to-hide-full-screen-button-of-mac-os-window-in-javafx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!