[java] Images
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.
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:
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement