Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Proper use of setIcon  RSS feed

 
Bob Sale
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am developing a simple image editor and need the user to be able to change the iconImage displayed in a JLabel. If I use setIcon to change the image, am I adding layer upon layer of iconImages on the JLabel (thus unnecessarily consuming memory) or does setIcon remove the previous icon (icon1) and add the new one (icon2)?

If I have to manage the removal process myself, how do I do so?

 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Imagine setIcon() method is any setXXX methods() in POJO. What happens if XXX is set? Replaced or new instance is created?

However keeping track of which JLabel's icon need changing is something you should consider.
 
Bob Sale
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you K.Tsang

Bob
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!