JavaFX Application Icon

后端 未结 17 1719
滥情空心
滥情空心 2020-11-28 02:25

Is it possible to change the application icon using JavaFX, or does it have to be done using Swing?

17条回答
  •  悲&欢浪女
    2020-11-28 02:34

    If you have have a images folder and the icon is saved in that use this

    stage.getIcons().add(new Image(.class.getResourceAsStream("/images/comparison.png")));
    

    and if you are directly using it from your package which is not a good practice use this

    stage.getIcons().add(new Image(.class.getResourceAsStream("comparison.png")));
    

    and if you have a folder structure and you have your icon inside that use

    stage.getIcons().add(new Image(.class.getResourceAsStream("../images/comparison.png")));
    

提交回复
热议问题