wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes How to add images Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to add images" Watch "How to add images" New topic
Author

How to add images

Garry Kalra
Ranch Hand

Joined: May 25, 2001
Posts: 111
Pls suggest me what we can use to add images to panels and display them in an application.
It would be helpful if somebody could provide the names of the widgets.
Gaurav
anandh
Greenhorn

Joined: Sep 06, 2001
Posts: 22
Try this:
Icon imageIcon = new ImageIcon("MyImage.jpg");
JPanel myPanel = new JPanel();
myPanel.add(new JLabel(imageIcon));
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to add images