JavaFX 8 How to set program icon to alert?

前端 未结 4 788
温柔的废话
温柔的废话 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:14

    The correct implementation is following comments above:

    // Get the Stage.
    Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
    
    // Add a custom icon.
    stage.getIcons().add(new Image(getClass().getResourceAsStream("images/logo_full3.png")));
    

提交回复
热议问题