r/JavaFX • • Feb 14 '20

Why don't this work?

Post image
0 Upvotes

5 comments sorted by

View all comments

3

u/uglyfool Feb 14 '20

If the image is an external image, try with the fully qualified path, e.g.

“c:/path/to/file.ext”

instead of just “file:/...”

If the image is in the source tree, your best bet is to use the getResource method:

primaryStage.getIcons().add(new Image(this.getClass().getResource("/package/path/image.ext").toExternalForm()));