I wrote this
Image icon = new ImageIcon(getClass().getResource("files/icon.png")).getImage();
in a JFrame-extending class to then set the icon of the frame with
this.setIconImage(icon);
I do it this way, intead of by simply using the Path, because otherwise the Icon would disappear, if I exported my Project as an executable .jar. (as seen here: Once exported, java cannot find/draw images)
The problem that occurs now is, that the executable .jar works the way it should (It creates a folder, as well as a .xml-file and writes into it), but without generating a visible frame. If I run the program in eclipse however, everything works fine and I see the frame. I found out, that the problem has to be in the creation of an ImageIcon, because if I run
getClass().getResource("files/icon.png");
everything works fine. The file is at it's place, too, so this shouldn't be the mistake.
Hope you can help me and thanks in advance.
Aucun commentaire:
Enregistrer un commentaire