How do you set the icon of a Dialog control Java FX/Java 8

后端 未结 4 2083
臣服心动
臣服心动 2021-02-07 05:15

I might be missing something very obvious, but I can\'t find out how to set the Icon for a Dialog component (ProgressDialog to be more precise). I know how to do that for a Stag

4条回答
  •  深忆病人
    2021-02-07 05:52

    You can easily use the icon of your application for the alert-icon by setting your application-window as owner of the alert box:

    @FXML
    Button buShow;
    ...
    
    Alert alert = new Alert(AlertType.INFORMATION, "Nice Box.", ButtonType.CLOSE);
    alert.initOwner(buShow.getScene().getWindow());   // Alert uses the Windows Icon
    alert.show();
    

提交回复
热议问题