img
FIGURE 25-3
Sample
output from
TrackedImageLoad
This example creates a new MediaTracker in the init( ) method and then adds each of the
named images as a tracked image with addImage( ). In the paint( ) method, it calls checkID( )
on each of the images that we're tracking. If all of the images are loaded, they are displayed.
If not, a simple bar chart of the number of images loaded is shown, with the names of the
fully loaded images displayed underneath the bar. Figure 25-3 shows two scenes from this
applet running. One is the bar chart, displaying that three of the images have been loaded.
The other is the Van Gogh self-portrait during the slide show.
ImageProducer
ImageProducer is an interface for objects that want to produce data for images. An object that
implements the ImageProducer interface will supply integer or byte arrays that represent
image data and produce Image objects. As you saw earlier, one form of the createImage( )
method takes an ImageProducer object as its argument. There are two image producers
contained in java.awt.image: MemoryImageSource and FilteredImageSource. Here, we
will examine MemoryImageSource and create a new Image object from data generated in
an applet.
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home