Problem in setting icon for JFrame!

Joined
Oct 22, 2008
Messages
1
Reaction score
0
hi all,
I want to change the icon of the JFrame. I have done this by coding. It is working fine in NetBeans IDE. But it is not displaying the icon after building jar.
I am getting this problem when i am trying to run the jar file.

I have tried the following codes. But they are not working after building jar.
(I kept the image file in resources folder).
Please go through it and suggest me possible workarounds.

-----------
this.setIconImage(java.awt.Toolkit.getDefaultToolk it().getImage("myicon.jpg"));
-----------
this.setIconImage(java.awt.Toolkit.getDefaultToolk it().getImage(Step1.class.getResource("myicon.jpg" )));
-----------
InputStream imgStream = this.getClass().getResourceAsStream("myicon.jpg");
BufferedImage bi = ImageIO.read(imgStream);
ImageIcon myImg = new ImageIcon(bi);
this.setIconImage(myImg.getImage());
------------

Thanks in advance!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top