JavaFX 8 How to set program icon to alert?

前端 未结 4 785
温柔的废话
温柔的废话 2021-01-19 01:29

How can I set program icon to alert without using alert.initOwner()? Why without initOwner? It\'s because some alert must be shown before whole win

4条回答
  •  抹茶落季
    2021-01-19 02:33

    public class AlertWithIcon
    extends Application {
        @Override
        public void start(Stage stage) {
            Alert alert = new Alert(Alert.AlertType.CONFIRMATION,
                "Are you sure you want to delete this item?",
            ButtonType.YES, ButtonType.NO);    
           alert.setHeaderText("Delete Item"); 
       ((Stage)alert.getDialogPane().getScene().getWindow()).getIcons().add(new image("GenericApp.png"));
        alert.showAndWait();
    }
    }
    

提交回复
热议问题