Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Refreshing of ImageIcon/JLabel  RSS feed

 
Adrian Lee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone. I need your help in clarifying some of my doubts, hope you can help me out.

I've created a java program which download images from the server. After the download is complete, the program will create another UI displaying the downloaded images.
I'm able to repeat the downloading process, each time downloading different images.
The images is displayed correctly on the first attempt. However, on the subsequent download, the image displayed on the UI wasn't refreshed although the image in the system has changed.

My question is :
1) Can I set/refresh the same ImageIcon which I've created/used earlier?
e.g
Label[1].setIcon(MovieImage[1]);

Thanks in advance
 
Brian Cole
Author
Ranch Hand
Posts: 935
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Changing the JLabel's icon with setIcon() should work fine. If it's not working for you, then I guess we need more information.
 
Adrian Lee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Brian. I'm trying to reuse the ImageIcons that I've created previously. Somehow the whole thing don't work for me. Even though the images has been overwrite, my UI program still displays the old images.

Can the ImageIcons be reused?

Thanks for your reply.
 
Brian Cole
Author
Ranch Hand
Posts: 935
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Adrian Lee:
I'm trying to reuse the ImageIcons that I've created previously. Somehow the whole thing don't work for me. Even though the images has been overwrite, my UI program still displays the old images.

Can the ImageIcons be reused?


I'm not sure what you mean by "the images has been overwrite" but, yes, you may reuse an ImageIcon. You may even use an ImageIcon several times simultaneously.

If you're having some problems, perhaps you should show us some code.
 
Adrian Lee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Brian and thanks for clearing my doubt on ImageIcon. My code is rather long, so I'll just post some of it here.

Basically, I'll call a socket program to do a download of images whenever I require. Everything is running smootthly except for the ImageIcon refresh part.


I'm still trying to figure out why my ImageIcon on the label can't be refreshed.
[ April 28, 2008: Message edited by: Adrian Lee ]
 
Adrian Lee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've found another method to go through this. Thanks for your help.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!