#What's the different between ImageIcon and Image?

1 messages · Page 1 of 1 (latest)

nimble marsh
#

Hi, I'm new to Java and am currently learning how to do animation.
And I am confused that why I should use Image but not ImageIcon when making animation.
And why should I use ImageIcon but not Image when adding an icon to a button, label, etc.?
What's the difference between them?
Thanks.

next gazelleBOT
#

This post has been reserved for your question.

Hey @nimble marsh! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

regal oak
#

there are other implementations of Icon but this specific one uses Image

#

when adding to a button/label/etc, those things expect an Icon , so you use an ImageIcon to say "hey here's the icon you wanted, shhh don't tell anybody but it's actually just an image"

nimble marsh
regal oak
#

if we look at "All Known Implementing Classes" here:

#

we can see that there are other implementations of Icon that aren't from an Image (most of them reference "Metal" which is the built-in java look-and-feel)

nimble marsh
#

got it! Thanks 🙂

next gazelleBOT
# nimble marsh got it! Thanks 🙂

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.