4

I have developed a Swing application using some image icons. The application jar file is working as expected in Windows but same jar file is not displaying image icon of frame on Ubuntu 12.04 operating system.

My sample code:

 ImageIcon ImageIcon = new ImageIcon(getClass().getResource("/images/logo.png"));
 Image Image = ImageIcon.getImage();
 frame.setIconImage(Image);

Note: images with buttons are displaying as expected, the problem is only with the loading of the frame image.

Can anybody suggest me how to resolve this one?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
krish131
  • 163
  • 3
  • 14
  • 5
    Please watch your variable naming scheme. Java is Camel case, thus `ImageIcon` should be `imageIcon`; variables begin with lower case and every new word thereafter gets capitalized. – David Kroukamp Dec 20 '12 at 21:30
  • Can you embed `logo.png` as an edit in the question? Where did it come from? Did you make it? One experiment is to open and 'save as' the image using your favorite image editor. Hopefully it will write a generic flavor of PNG that is understood by all readers. – Andrew Thompson Dec 21 '12 at 10:36
  • @DavidKroukamp the variable declaration was fine..unfortunately i wrote imageIcon as ImageIcon here. – krish131 Dec 21 '12 at 16:03
  • @AndrewThompson I was not supposed to embed my logo here. I have converted my original jpg image to .png format. it is working in windows. – krish131 Dec 21 '12 at 16:15

1 Answers1

1

Set your JFrame look and feel to decorated,

JFrame.setDefaultLookAndFeelDecorated(true);
TeaCupApp
  • 11,316
  • 18
  • 70
  • 150