0 votes
1 view
in Java by (10.2k points)

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

1 Answer

0 votes
by (46.1k points)

Assuming your stage is "stage" and the file is on the filesystem:

stage.getIcons().add(new Image("file:icon.png"));

As per the comment below, if it's wrapped in a containing jar you'll need to use the following approach instead:

stage.getIcons().add(new Image(<yourclassname>.class.getResourceAsStream("icon.png")));

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...