JavaFX 8 - Application Icon will only sometimes appear

274 views Asked by At

I'm adding my application icon with stage.getIcons().add(new Image("path")) and the icon will appear sometimes, so I know that the program can find the resource and I'm calling the right methods, but the icon won't appear every time. From what I can tell from this question this is probably because swing (which I believe JavaFX uses) loads images in a separate thread. If this is the problem, how can I ensure that loading and adding the icon finishes before I call stage.show()? If this is not the problem, what is going on here and what am I doing wrong? I'm using JRuby so your answer can include Ruby libs if they're applicable. A purely Java answer is fine too.

1

There are 1 answers

0
AudioBubble On

Hello I think that the program process that loads the image does did not finish loading before you are showing it. You can add a wait() function after your icon addition. Or you can execute another function in between your add(new Image("pokemon.png")) and your primaryStage.show() this will ensure that your image load will finish before you show the stage.