2

How can I change the icon of a Gluon Desktop app? I changed the icon.png file, but that seems to only be used in the about dialog.

I'm using IntelliJ IDEA 16.

1 Answers1

1

Application class has a postInit method you can override. Scene is passed into it. Once you get the scene you can get the stage from it and than use normal JavaFX way to set the icon.

Stage stage = (Stage)(scene.getWindow());
stage.getIcons().add(new Image("file:icon.png"));
Eugene Ryzhikov
  • 17,131
  • 3
  • 38
  • 60
  • When I try to get the stage inside of `postInit`, I'm getting stage as null. Any idea why? –  Apr 03 '16 at 21:57
  • 1
    That means the window is not created yet. You can attach a change listener to `scene.windowProperty` to determine when window(stage) changes – Eugene Ryzhikov Apr 04 '16 at 12:34