O'Reilly logo

Graphic Java™ 1.2, Volume I: AWT, Third Edition by David M. Geary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required