MediaTracker

The java.awt.MediaTracker class provides a more convenient way than we've illustrated thus far to manage the asynchronous loading of an image. Essentially, an instance of MediaTracker can track the loading of an image. The applet in Example 5-7 employs an instance of MediaTracker to fully load the image before it is drawn.

Example 5-7. Image Loading With the MediaTracker Class
 import java.net.URL; import java.applet.Applet; import java.awt.Graphics; import java.awt.Image; import java.awt.MediaTracker; public class ImageTestAppletWithMediaTracker extends Applet { private Image im; public void init() { MediaTracker tracker = new MediaTracker(this); ...

Get Graphic Java™ 1.2, Volume I: AWT, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.