

Java™ Web Start ( download JDK 7 or later). Five of them display thumbnail images and the sixth displays the full-size photograph.Ĭlick the Launch button to run IconDemo using Here's an application that uses six image icons.

When the image is not part of the application, getResource should not be used and the ImageIcon constructor is used directly.


This allows the application to verify that the image is available and to provide sensible error handling if it is not. You should use the Class getResource method to obtain the path to the image. Generally, applications provide their own set of images used as part of the application, as is the case with the images used by many of our demos. The description argument is a string that allows assistive technologies to help a visually impaired user understand what information the icon conveys. In the preceding snippet, the first argument to the ImageIcon constructor is relative to the location of the current class, and will be resolved to an absolute URL. Return new ImageIcon(imgURL, description) Protected ImageIcon createImageIcon(String path, ** Returns an ImageIcon, or null if the path was invalid.
