9.12. Drawing Images

Applets and applications written in the Java programming language can load and display static images in GIF or JPEG format, as well as GIF89A images (a.k.a. “animated GIF”).

Image drawing is done in two steps. First, a remote or local image is registered by means of the getImage method of Applet or Toolkit. Second, the image is drawn on the screen with the drawImage method of Graphics. You can draw the image at its regular size or supply an explicit width and height. The key point to remember is that calls to getImage don't actually initiate image loading. Instead, Java technology doesn't start loading the image until it is needed.

Actual loading of the image is done in a background thread, and the image can be drawn incrementally ...

Get Core Web Programming, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.