Resource icons Jframe

Asked

Viewed 88 times

1

Good afternoon.

I’m having trouble with my app. It executes with changing the icon on JFrame. When compiling it for: "Runnable Jar file" and compiling with: Launch4j for Inary, the application simply does not open.

I’m changing the icon by this command:

frame.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/z/app.png")));
  • Somebody give me a hand please!

  • There is not enough information in your question for someone to come up with a useful answer. In what context do you change the icon? How does /z/app.png is packaged in the application? Can you make a code minimum, complete and verifiable?

  • /z/app.png is inside the project folder at eclipse. specifically: F: Development- Eclipse Utilities Quickstage bin z inside the z folder is: "app.png" and "Tray.png"

  • Can you see if the icon appears somewhere inside the JAR file? What if this place is the expected place? In particular the use of getClass().getResource(String) is something very sensitive to fail depending on whether the application is encapsulated in a JAR file. Again, a MCVE would be helpful enough for you to get better and faster answers: http://answall.com/help/mcve

  • Victor champion! How can I see in ". jar"? Yes, I’m trying to use MVC. More on this part of image I don’t know how I would look inside it.

  • Rename it to ". zip" and open it as a ". zip". And don’t confuse MVC with MCVE, these are completely different things!

Show 1 more comment

1 answer

1

I created 1 package named img and changed the directory to:

frame.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/img/app.png")));
  • Doing this worked or the problem still persists?

  • 1

    Solved Victor. After you created 1 package and named it img and dragged the images.png folder to the img folder in the eclipse and referenced it again solved the problem. Even the "Tray system" which is hide next to the windows clock stopped giving error. Thank you for your attention! and for your help

Browser other questions tagged

You are not signed in. Login or sign up in order to post.