An ImageIcon is an implementation of the Icon interface in Java Swing.
An ImageIcon is an implementation of the Icon interface in Java Swing. ImageIcon paints an icon from GIF, JPEG, or PNG files1 2 or a java.awt.Image.
- Sources for images might be constructed from
File(rarely useful)Stringdenoting the path to aFile(N.B. often leads to the 'loading resource error mentioned below').URL(typically used for embedded-resource)ImageInputStreamthat is from/of an image.
- The image formats you can rely on the J2SE to handle is as above, JPG, PNG & GIF. OTOH Java based image I/O formats are provided by Service Provider Interface. Any particular JRE might support more formats.