ImageIcon class in Java2
Another class for using images in Java2 is ImageIcon, from javax.swing, which can again use both gifs and jpegs. ImageIcon icon = new ImageIcon ( picture.gif );
In addition to creating an ImageIcon from a file, there are constructors to create an ImageIcon from a URL or another Image.
ImageIcons are used in other swing components, but they can also be painted to any component, such as an applet: icon.paintIcon ( this, g, x, y );where this is the component in which it will be painted, g is the graphics context, and x and y are the coordinates of the upper left-hand corner.