wood burning stoves*
The moose likes Swing / AWT / SWT and the fly likes Working with ImageIcon. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Working with ImageIcon." Watch "Working with ImageIcon." New topic

Working with ImageIcon.

P Jain
Ranch Hand

Joined: Jul 31, 2004
Posts: 52
Initially I am having

Label_Image_Center =new JLabel(new ImageIcon("h3.jpg"));
Panel_Image.add(Label_Image_Center, new XYConstraints(19, 65, 123,141));

after clicking on button different images saves as "h3.jpg". (I mean the images gets change but the name of the image reamins same or we can say that that image is live snapshot which gets change with each button click but saved with same name)
Now, I am doing

Label_Image_Center.setIcon(new ImageIcon("h3.jpg"));
Panel_Image.add(Label_Image_Center, new XYConstraints(19, 65, 123,141));

but the image gets not change on the Label,though when I opens it(image) outside it show different image.

Regards<br />P Jain
Nigel Browne
Ranch Hand

Joined: May 15, 2001
Posts: 673
You probably have to set the first Icon to null before reloading the new Icon file.
I agree. Here's the link: http://aspose.com/file-tools
subject: Working with ImageIcon.
Similar Threads
what affects addActionListener(this)?
SetIconImage Question
Working with Image Icon
Standalone app worked... as Applet does not.
JButton size changes