• Post Reply Bookmark Topic Watch Topic
  • New Topic

Image or ImageIcon?  RSS feed

 
Don Gardner
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which is better to use? An Image or an ImageIcon? I've heard before that it is better not us mix AWT and Swing components, but does this hold true for Image and ImageIcons as well?
If I should use ImageIcon instead of Image, what is the eqivalent of:

for ImageIcons?
Do I need to create an Image using the above method, then convert it to an ImageIcon using:

, or is there a more direct method?
Thanks for the help,
Don
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope... no AWT/Swing problems between Image and ImageIcon. ImageIcon was added in Swing to make it easier to display graphics on a component without having to override that component's paint() method. An ImageIcon isn't an image... it holds an image. So you would create an ImageIcon from that MemoryImageSource the way that you mentioned.
 
Don Gardner
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the info!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!