[java] Images

Started by
1 comment, last by DefCom 21 years, 11 months ago
I can load images in applets and japplets but can not get them in to applications (JFrame). I have been using Image and ImageIcon and putting them in a label. I get no errors, but it does not display. Any Help would be much appriciated. Thankyou.
Advertisement
Hard to say without you being a bit more specific. Would it be possible for you to post the snippet you''re using to create the ImageIcon and label?

Here''s a quick example of code that I have used in order to display an image:

String fn = "images/picture.jpg";ImageIcon image = new ImageIcon( SplashScreen.class.getResource(fn)); JLabel pic = new JLabel(image); getContentPane().add(pic); 


Note that this code is inside a class that extends a JWindow, which is why I am calling getContentPane() like that. But you should get the idea.

-pirate_dau
Thanks got it now

I had not used the string and has gone straight into

ImageIcon image = new ImageIcon("Image.gif");
instead of
ImageIcon image = new ImageIcon( SplashScreen.class.getResource(fn));

Thanks once again.

This topic is closed to new replies.

Advertisement