Java: ImageIcon vs. Image difference

11,735

Solution 1

Their nature and application is different. Image is an abstract superclass of all classes that represent graphical images. ImageIcon is an implementation of Icon interface that uses Image as its source.

Edit: Think of an Image as something that could be rendered and an ImageIcon as something that will be rendered as an Icon when its paintIcon() method is called.

Edit: The links above will take you to the JDK 6 api. These links will take you to the JDK 8 api: Image and ImageIcon.

Solution 2

You can scale and save Image, but you can't do it with ImageIcon. For creating pictures in your GUI you usually have to use ImageIcon, but if you don't wanna do that, Image should be better.

Share:
11,735
ps-aux
Author by

ps-aux

Updated on June 23, 2022

Comments

  • ps-aux
    ps-aux almost 2 years

    Could anyone explain to me in noob way what the difference is betweeen ImageIcon and Image classes/objects in Java? Thanks