dcsimg
How to display an image using swing?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   vani_hemmige
Posted On:   Friday, March 23, 2001 11:14 AM

Hi,
I have an application which needs to open an image file and display it. To do this, I have derived the application from JFrame. I have inserted a "File" menu and in the "File-Open" action handler, I have used a FileChooser dialog which allows the user to select a file. When the user clicks OK, I want the the selected image file to be displayed in the main frame. Can anyone tell me how to do this?
Thanks,
Vani

Re: How to display an image using swing?

Posted By:   Scott_Stanchfield  
Posted On:   Wednesday, April 25, 2001 08:11 AM

Load the image into an ImageIcon, stick the icon on a JLabel, and put the JLabel in a JFrame.

For details, see the Swing FAQ

Re: How to display an image using swing?

Posted By:   Sandip_Chitale  
Posted On:   Sunday, March 25, 2001 06:30 PM



label.setIcon(new ImageIcon(fileDialog.getSelectedFile().getAbsolutePath());

About | Sitemap | Contact