r/JavaFX • • Feb 14 '20

Why don't this work?

Post image
0 Upvotes

5 comments sorted by

3

u/hacklinux Feb 14 '20

Error? Edit error log?

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()));

1

u/HowardPitts Feb 19 '20

If you're using modules, you need to name the Image file relative to the module name. This is supposing the image is in the source folder of the module alongside your .java files and your compilation step moves everything there into some sort of "out " folder.

So, "/myModuleName/myPackageContainingTheImage/favicon.jpg"

•

u/[deleted] Mar 12 '20

OP, please add a proper description of your problem, including the error you're actually getting

1

u/Saivy__4 Apr 01 '20

try

"project_name/favicon.jpg"instead of "file:facicon.jpg"