Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change default java logo exe icon on the taskbar in javafx?

I made a JavaFX application on Netbeans and I put this code for setting the icon to the window

primaryStage.getIcons().add(new Image("file:sicadcam.png"));

and when I run the project from Netbeans, it works ok: the icon appears on the window and in the taskbar. where I have to put the image.

When I clean and build the project, it generates two installers: one exe and one msi; and when I install the application and open it, the window doesn't have the icon sicadcam.png, it has the default java logo icon.

How or where can I set the path of the image so that when I install the application the icon appears.

like image 504
vijayk Avatar asked Feb 14 '23 13:02

vijayk


1 Answers

You should place the icon in your jar or classpath and then load it through a resource function. E.g. if you place it to your bin folder, into the package where your class is, then the following should work:

primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("sicadcam.png")));
like image 92
Udo Klimaschewski Avatar answered Feb 17 '23 01:02

Udo Klimaschewski