A programmer will typically also want to get away from the ugly gray buttons provided by the Java Virtual Machine implementation, and do some cool ones instead. This is almost the same thing as putting an image on the screen, except you need to detect when the user clicks on it, and give some visual feedback so the user knows they were heard. The ImageCanvas class provides both of these functions, making it trivial to write a simple slide viewer like this one which shows you some of the images used on this site.
There are three ImageCanvases in this applet.
The big yellow one at the top is just given an image whenever we want it changed.
The two buttons at the bottom are ImageCanvases which have been told to report
back to the applet whenever they're clicked on.
At the same time, they switch over to a second image for 200 milliseconds.
By the way, Graphics.drawImage does recognise transparent colours in GIFs.
The ImageCanvas is compatible with the JDK 1.02 event model, in particular
when acting as an image button it will call mouseDown in its event handler.
The preferredSize() of the ImageCanvas is the size of the primary image.