• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Image or ImageIcon?

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the info!
 
Why fit in when you were born to stand out? - Seuss. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic