java.awt
Class MediaTracker

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.awt.MediaTracker
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable

public class MediaTracker
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements Serializable sample code for java.io.Serializable definition code for java.io.Serializable

The MediaTracker class is a utility class to track the status of a number of media objects. Media objects could include audio clips as well as images, though currently only images are supported.

To use a media tracker, create an instance of MediaTracker and call its addImage method for each image to be tracked. In addition, each image can be assigned a unique identifier. This identifier controls the priority order in which the images are fetched. It can also be used to identify unique subsets of the images that can be waited on independently. Images with a lower ID are loaded in preference to those with a higher ID number.

Tracking an animated image might not always be useful due to the multi-part nature of animated image loading and painting, but it is supported. MediaTracker treats an animated image as completely loaded when the first frame is completely loaded. At that point, the MediaTracker signals any waiters that the image is completely loaded. If no ImageObservers are observing the image when the first frame has finished loading, the image might flush itself to conserve resources (see Image.flush() sample code for java.awt.Image.flush() definition code for java.awt.Image.flush() ).

Here is an example of using MediaTracker:


 import java.applet.Applet;
 import java.awt.Color;
 import java.awt.Image;
 import java.awt.Graphics;
 import java.awt.MediaTracker;

 public class ImageBlaster extends Applet implements Runnable {
        MediaTracker tracker;
        Image bg;
        Image anim[] = new Image[5];
        int index;
        Thread animator;

        // Get the images for the background (id == 0) 
        // and the animation frames (id == 1) 
        // and add them to the MediaTracker
        public void init() {
            tracker = new MediaTracker(this);
            bg = getImage(getDocumentBase(), 
                  "images/background.gif");
            tracker.addImage(bg, 0);
            for (int i = 0; i < 5; i++) {
                anim[i] = getImage(getDocumentBase(), 
                      "images/anim"+i+".gif");
                tracker.addImage(anim[i], 1);
            }
        }

        // Start the animation thread.
        public void start() {
            animator = new Thread(this);
            animator.start();
        }

        // Stop the animation thread.
        public void stop() {
            animator = null;
        }

        // Run the animation thread.
        // First wait for the background image to fully load 
        // and paint.  Then wait for all of the animation 
        // frames to finish loading. Finally, loop and 
        // increment the animation frame index.
        public void run() {
            try {
                tracker.waitForID(0);
                tracker.waitForID(1);
            } catch (InterruptedException e) {
                return;
            }
            Thread me = Thread.currentThread();
            while (animator == me) {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    break;
                }
                synchronized (this) {
                    index++;
                    if (index >= anim.length) {
                        index = 0;
                    }
                }
                repaint();
            }
        }

        // The background image fills the frame so we 
        // don't need to clear the applet on repaints. 
        // Just call the paint method.
        public void update(Graphics g) {
            paint(g);
        }

        // Paint a large red rectangle if there are any errors 
        // loading the images.  Otherwise always paint the 
        // background so that it appears incrementally as it 
        // is loading.  Finally, only paint the current animation 
        // frame if all of the frames (id == 1) are done loading,
        // so that we don't get partial animations.
        public void paint(Graphics g) {
            if ((tracker.statusAll(false) & MediaTracker.ERRORED) != 0) {
                g.setColor(Color.red);
                g.fillRect(0, 0, size().width, size().height);
                return;
            }
            g.drawImage(bg, 0, 0, this);
            if (tracker.statusID(1, false) == MediaTracker.COMPLETE) {
                g.drawImage(anim[index], 10, 10, this);
            }
        }
 }
 

Since:
JDK1.0
See Also:
Serialized Form

Field Summary
static int ABORTED sample code for java.awt.MediaTracker.ABORTED definition code for java.awt.MediaTracker.ABORTED
          Flag indicating that the downloading of media was aborted.
static int COMPLETE sample code for java.awt.MediaTracker.COMPLETE definition code for java.awt.MediaTracker.COMPLETE
          Flag indicating that the downloading of media was completed successfully.
static int ERRORED sample code for java.awt.MediaTracker.ERRORED definition code for java.awt.MediaTracker.ERRORED
          Flag indicating that the downloading of media encountered an error.
static int LOADING sample code for java.awt.MediaTracker.LOADING definition code for java.awt.MediaTracker.LOADING
          Flag indicating that media is currently being loaded.
 
Constructor Summary
MediaTracker sample code for java.awt.MediaTracker.MediaTracker(java.awt.Component) definition code for java.awt.MediaTracker.MediaTracker(java.awt.Component) (Component sample code for java.awt.Component definition code for java.awt.Component  comp)
          Creates a media tracker to track images for a given component.
 
Method Summary
 void addImage sample code for java.awt.MediaTracker.addImage(java.awt.Image, int) definition code for java.awt.MediaTracker.addImage(java.awt.Image, int) (Image sample code for java.awt.Image definition code for java.awt.Image  image, int id)
          Adds an image to the list of images being tracked by this media tracker.
 void addImage sample code for java.awt.MediaTracker.addImage(java.awt.Image, int, int, int) definition code for java.awt.MediaTracker.addImage(java.awt.Image, int, int, int) (Image sample code for java.awt.Image definition code for java.awt.Image  image, int id, int w, int h)
          Adds a scaled image to the list of images being tracked by this media tracker.
 boolean checkAll sample code for java.awt.MediaTracker.checkAll() definition code for java.awt.MediaTracker.checkAll() ()
          Checks to see if all images being tracked by this media tracker have finished loading.
 boolean checkAll sample code for java.awt.MediaTracker.checkAll(boolean) definition code for java.awt.MediaTracker.checkAll(boolean) (boolean load)
          Checks to see if all images being tracked by this media tracker have finished loading.
 boolean checkID sample code for java.awt.MediaTracker.checkID(int) definition code for java.awt.MediaTracker.checkID(int) (int id)
          Checks to see if all images tracked by this media tracker that are tagged with the specified identifier have finished loading.
 boolean checkID sample code for java.awt.MediaTracker.checkID(int, boolean) definition code for java.awt.MediaTracker.checkID(int, boolean) (int id, boolean load)
          Checks to see if all images tracked by this media tracker that are tagged with the specified identifier have finished loading.
 Object sample code for java.lang.Object definition code for java.lang.Object [] getErrorsAny sample code for java.awt.MediaTracker.getErrorsAny() definition code for java.awt.MediaTracker.getErrorsAny() ()
          Returns a list of all media that have encountered an error.
 Object sample code for java.lang.Object definition code for java.lang.Object [] getErrorsID sample code for java.awt.MediaTracker.getErrorsID(int) definition code for java.awt.MediaTracker.getErrorsID(int) (int id)
          Returns a list of media with the specified ID that have encountered an error.
 boolean isErrorAny sample code for java.awt.MediaTracker.isErrorAny() definition code for java.awt.MediaTracker.isErrorAny() ()
          Checks the error status of all of the images.
 boolean isErrorID sample code for java.awt.MediaTracker.isErrorID(int) definition code for java.awt.MediaTracker.isErrorID(int) (int id)
          Checks the error status of all of the images tracked by this media tracker with the specified identifier.
 void removeImage sample code for java.awt.MediaTracker.removeImage(java.awt.Image) definition code for java.awt.MediaTracker.removeImage(java.awt.Image) (Image sample code for java.awt.Image definition code for java.awt.Image  image)
          Removes the specified image from this media tracker.
 void removeImage sample code for java.awt.MediaTracker.removeImage(java.awt.Image, int) definition code for java.awt.MediaTracker.removeImage(java.awt.Image, int) (Image sample code for java.awt.Image definition code for java.awt.Image  image, int id)
          Removes the specified image from the specified tracking ID of this media tracker.
 void removeImage sample code for java.awt.MediaTracker.removeImage(java.awt.Image, int, int, int) definition code for java.awt.MediaTracker.removeImage(java.awt.Image, int, int, int) (Image sample code for java.awt.Image definition code for java.awt.Image  image, int id, int width, int height)
          Removes the specified image with the specified width, height, and ID from this media tracker.
 int statusAll sample code for java.awt.MediaTracker.statusAll(boolean) definition code for java.awt.MediaTracker.statusAll(boolean) (boolean load)
          Calculates and returns the bitwise inclusive OR of the status of all media that are tracked by this media tracker.
 int statusID sample code for java.awt.MediaTracker.statusID(int, boolean) definition code for java.awt.MediaTracker.statusID(int, boolean) (int id, boolean load)
          Calculates and returns the bitwise inclusive OR of the status of all media with the specified identifier that are tracked by this media tracker.
 void waitForAll sample code for java.awt.MediaTracker.waitForAll() definition code for java.awt.MediaTracker.waitForAll() ()
          Starts loading all images tracked by this media tracker.
 boolean waitForAll sample code for java.awt.MediaTracker.waitForAll(long) definition code for java.awt.MediaTracker.waitForAll(long) (long ms)
          Starts loading all images tracked by this media tracker.
 void waitForID sample code for java.awt.MediaTracker.waitForID(int) definition code for java.awt.MediaTracker.waitForID(int) (int id)
          Starts loading all images tracked by this media tracker with the specified identifier.
 boolean waitForID sample code for java.awt.MediaTracker.waitForID(int, long) definition code for java.awt.MediaTracker.waitForID(int, long) (int id, long ms)
          Starts loading all images tracked by this media tracker with the specified identifier.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

LOADING sample code for java.awt.MediaTracker.LOADING

public static final int LOADING
Flag indicating that media is currently being loaded.

See Also:
statusAll(boolean) sample code for java.awt.MediaTracker.statusAll(boolean) definition code for java.awt.MediaTracker.statusAll(boolean) , statusID(int, boolean) sample code for java.awt.MediaTracker.statusID(int, boolean) definition code for java.awt.MediaTracker.statusID(int, boolean) , Constant Field Values

ABORTED sample code for java.awt.MediaTracker.ABORTED

public static final int ABORTED
Flag indicating that the downloading of media was aborted.

See Also:
statusAll(boolean) sample code for java.awt.MediaTracker.statusAll(boolean) definition code for java.awt.MediaTracker.statusAll(boolean) , statusID(int, boolean) sample code for java.awt.MediaTracker.statusID(int, boolean) definition code for java.awt.MediaTracker.statusID(int, boolean) , Constant Field Values

ERRORED sample code for java.awt.MediaTracker.ERRORED

public static final int ERRORED
Flag indicating that the downloading of media encountered an error.

See Also:
statusAll(boolean) sample code for java.awt.MediaTracker.statusAll(boolean) definition code for java.awt.MediaTracker.statusAll(boolean) , statusID(int, boolean) sample code for java.awt.MediaTracker.statusID(int, boolean) definition code for java.awt.MediaTracker.statusID(int, boolean) , Constant Field Values

COMPLETE sample code for java.awt.MediaTracker.COMPLETE

public static final int COMPLETE
Flag indicating that the downloading of media was completed successfully.

See Also:
statusAll(boolean) sample code for java.awt.MediaTracker.statusAll(boolean) definition code for java.awt.MediaTracker.statusAll(boolean) , statusID(int, boolean) sample code for java.awt.MediaTracker.statusID(int, boolean) definition code for java.awt.MediaTracker.statusID(int, boolean) , Constant Field Values
Constructor Detail

MediaTracker sample code for java.awt.MediaTracker(java.awt.Component) definition code for java.awt.MediaTracker(java.awt.Component)

public MediaTracker(Component sample code for java.awt.Component definition code for java.awt.Component  comp)
Creates a media tracker to track images for a given component.

Parameters:
comp - the component on which the images will eventually be drawn
Method Detail

addImage sample code for java.awt.MediaTracker.addImage(java.awt.Image, int) definition code for java.awt.MediaTracker.addImage(java.awt.Image, int)

public void addImage(Image sample code for java.awt.Image definition code for java.awt.Image  image,
                     int id)
Adds an image to the list of images being tracked by this media tracker. The image will eventually be rendered at its default (unscaled) size.

Parameters:
image - the image to be tracked
id - an identifier used to track this image

addImage sample code for java.awt.MediaTracker.addImage(java.awt.Image, int, int, int) definition code for java.awt.MediaTracker.addImage(java.awt.Image, int, int, int)

public void addImage(Image sample code for java.awt.Image definition code for java.awt.Image  image,
                     int id,
                     int w,
                     int h)
Adds a scaled image to the list of images being tracked by this media tracker. The image will eventually be rendered at the indicated width and height.

Parameters:
image - the image to be tracked
id - an identifier that can be used to track this image
w - the width at which the image is rendered
h - the height at which the image is rendered

checkAll sample code for java.awt.MediaTracker.checkAll() definition code for java.awt.MediaTracker.checkAll()

public boolean checkAll()
Checks to see if all images being tracked by this media tracker have finished loading.

This method does not start loading the images if they are not already loading.

If there is an error while loading or scaling an image, then that image is considered to have finished loading. Use the isErrorAny or isErrorID methods to check for errors.

Returns:
true if all images have finished loading, have been aborted, or have encountered an error; false otherwise
See Also:
checkAll(boolean) sample code for java.awt.MediaTracker.checkAll(boolean) definition code for java.awt.MediaTracker.checkAll(boolean) , checkID(int) sample code for java.awt.MediaTracker.checkID(int) definition code for java.awt.MediaTracker.checkID(int) , isErrorAny() sample code for java.awt.MediaTracker.isErrorAny() definition code for java.awt.MediaTracker.isErrorAny() , isErrorID(int) sample code for java.awt.MediaTracker.isErrorID(int) definition code for java.awt.MediaTracker.isErrorID(int)

checkAll sample code for java.awt.MediaTracker.checkAll(boolean) definition code for java.awt.MediaTracker.checkAll(boolean)

public boolean checkAll(boolean load)
Checks to see if all images being tracked by this media tracker have finished loading.

If the value of the load flag is true, then this method starts loading any images that are not yet being loaded.

If there is an error while loading or scaling an image, that image is considered to have finished loading. Use the isErrorAny and isErrorID methods to check for errors.

Parameters:
load - if true, start loading any images that are not yet being loaded
Returns:
true if all images have finished loading, have been aborted, or have encountered an error; false otherwise
See Also:
checkID(int) sample code for java.awt.MediaTracker.checkID(int) definition code for java.awt.MediaTracker.checkID(int) , checkAll() sample code for java.awt.MediaTracker.checkAll() definition code for java.awt.MediaTracker.checkAll() , isErrorAny() sample code for java.awt.MediaTracker.isErrorAny() definition code for java.awt.MediaTracker.isErrorAny() , isErrorID(int) sample code for java.awt.MediaTracker.isErrorID(int) definition code for java.awt.MediaTracker.isErrorID(int)

isErrorAny sample code for java.awt.MediaTracker.isErrorAny() definition code for java.awt.MediaTracker.isErrorAny()

public boolean isErrorAny()
Checks the error status of all of the images.

Returns:
true if any of the images tracked by this media tracker had an error during loading; false otherwise
See Also:
isErrorID(int) sample code for java.awt.MediaTracker.isErrorID(int) definition code for java.awt.MediaTracker.isErrorID(int) , getErrorsAny() sample code for java.awt.MediaTracker.getErrorsAny() definition code for java.awt.MediaTracker.getErrorsAny()

getErrorsAny sample code for java.awt.MediaTracker.getErrorsAny() definition code for java.awt.MediaTracker.getErrorsAny()

public Object sample code for java.lang.Object definition code for java.lang.Object [] getErrorsAny()
Returns a list of all media that have encountered an error.

Returns:
an array of media objects tracked by this media tracker that have encountered an error, or null if there are none with errors
See Also:
isErrorAny() sample code for java.awt.MediaTracker.isErrorAny() definition code for java.awt.MediaTracker.isErrorAny() , getErrorsID(int) sample code for java.awt.MediaTracker.getErrorsID(int) definition code for java.awt.MediaTracker.getErrorsID(int)

waitForAll sample code for java.awt.MediaTracker.waitForAll() definition code for java.awt.MediaTracker.waitForAll()

public void waitForAll()
                throws InterruptedException sample code for java.lang.InterruptedException definition code for java.lang.InterruptedException 
Starts loading all images tracked by this media tracker. This method waits until all the images being tracked have finished loading.

If there is an error while loading or scaling an image, then that image is considered to have finished loading. Use the isErrorAny or isErrorID methods to check for errors.

Throws:
InterruptedException sample code for java.lang.InterruptedException definition code for java.lang.InterruptedException - if another thread has interrupted this thread
See Also:
waitForID(int) sample code for java.awt.MediaTracker.waitForID(int) definition code for java.awt.MediaTracker.waitForID(int) , waitForAll(long) sample code for java.awt.MediaTracker.waitForAll(long) definition code for java.awt.MediaTracker.waitForAll(long) , isErrorAny() sample code for java.awt.MediaTracker.isErrorAny() definition code for java.awt.MediaTracker.isErrorAny() , isErrorID(int) sample code for java.awt.MediaTracker.isErrorID(int) definition code for java.awt.MediaTracker.isErrorID(int)

waitForAll sample code for java.awt.MediaTracker.waitForAll(long) definition code for java.awt.MediaTracker.waitForAll(long)

public boolean waitForAll(long ms)
                   throws InterruptedException sample code for java.lang.InterruptedException definition code for java.lang.InterruptedException 
Starts loading all images tracked by this media tracker. This method waits until all the images being tracked have finished loading, or until the length of time specified in milliseconds by the ms argument has passed.

If there is an error while loading or scaling an image, then that image is considered to have finished loading. Use the isErrorAny or isErrorID methods to check for errors.

Parameters:
ms - the number of milliseconds to wait for the loading to complete
Returns:
true if all images were successfully loaded; false otherwise
Throws:
InterruptedException sample code for java.lang.InterruptedException definition code for java.lang.InterruptedException - if another thread has interrupted this thread.
See Also:
waitForID(int) sample code for java.awt.MediaTracker.waitForID(int) definition code for java.awt.MediaTracker.waitForID(int) , waitForAll(long) sample code for java.awt.MediaTracker.waitForAll(long) definition code for java.awt.MediaTracker.waitForAll(long) , isErrorAny() sample code for java.awt.MediaTracker.isErrorAny() definition code for java.awt.MediaTracker.isErrorAny() , isErrorID(int) sample code for java.awt.MediaTracker.isErrorID(int) definition code for java.awt.MediaTracker.isErrorID(int)

statusAll sample code for java.awt.MediaTracker.statusAll(boolean) definition code for java.awt.MediaTracker.statusAll(boolean)

public int statusAll(boolean load)
Calculates and returns the bitwise inclusive OR of the status of all media that are tracked by this media tracker.

Possible flags defined by the MediaTracker class are LOADING, ABORTED, ERRORED, and COMPLETE. An image that hasn't started loading has zero as its status.

If the value of load is true, then this method starts loading any images that are not yet being loaded.

Parameters:
load - if true, start loading any images that are not yet being loaded
Returns:
the bitwise inclusive OR of the status of all of the media being tracked
See Also:
statusID(int, boolean) sample code for java.awt.MediaTracker.statusID(int, boolean) definition code for java.awt.MediaTracker.statusID(int, boolean) , LOADING sample code for java.awt.MediaTracker.LOADING definition code for java.awt.MediaTracker.LOADING , ABORTED sample code for java.awt.MediaTracker.ABORTED definition code for java.awt.MediaTracker.ABORTED , ERRORED sample code for java.awt.MediaTracker.ERRORED definition code for java.awt.MediaTracker.ERRORED , COMPLETE sample code for java.awt.MediaTracker.COMPLETE definition code for java.awt.MediaTracker.COMPLETE

checkID sample code for java.awt.MediaTracker.checkID(int) definition code for java.awt.MediaTracker.checkID(int)

public boolean checkID(int id)
Checks to see if all images tracked by this media tracker that are tagged with the specified identifier have finished loading.

This method does not start loading the images if they are not already loading.

If there is an error while loading or scaling an image, then that image is considered to have finished loading. Use the isErrorAny or isErrorID methods to check for errors.

Parameters:
id - the identifier of the images to check
Returns:
true if all images have finished loading, have been aborted, or have encountered an error; false otherwise
See Also:
checkID(int, boolean) sample code for java.awt.MediaTracker.checkID(int, boolean) definition code for java.awt.MediaTracker.checkID(int, boolean) , checkAll() sample code for java.awt.MediaTracker.checkAll() definition code for java.awt.MediaTracker.checkAll() , isErrorAny() sample code for java.awt.MediaTracker.isErrorAny() definition code for java.awt.MediaTracker.isErrorAny() , isErrorID(int) sample code for java.awt.MediaTracker.isErrorID(int) definition code for java.awt.MediaTracker.isErrorID(int)

checkID sample code for java.awt.MediaTracker.checkID(int, boolean) definition code for java.awt.MediaTracker.checkID(int, boolean)

public boolean checkID(int id,
                       boolean load)
Checks to see if all images tracked by this media tracker that are tagged with the specified identifier have finished loading.

If the value of the load flag is true, then this method starts loading any images that are not yet being loaded.

If there is an error while loading or scaling an image, then that image is considered to have finished loading. Use the isErrorAny or isErrorID methods to check for errors.

Parameters:
id - the identifier of the images to check
load - if true, start loading any images that are not yet being loaded
Returns:
true if all images have finished loading, have been aborted, or have encountered an error; false otherwise
See Also:
checkID(int, boolean) sample code for java.awt.MediaTracker.checkID(int, boolean) definition code for java.awt.MediaTracker.checkID(int, boolean) , checkAll() sample code for java.awt.MediaTracker.checkAll() definition code for java.awt.MediaTracker.checkAll() , isErrorAny() sample code for java.awt.MediaTracker.isErrorAny() definition code for java.awt.MediaTracker.isErrorAny() , isErrorID(int) sample code for java.awt.MediaTracker.isErrorID(int) definition code for java.awt.MediaTracker.isErrorID(int)

isErrorID sample code for java.awt.MediaTracker.isErrorID(int) definition code for java.awt.MediaTracker.isErrorID(int)

public boolean isErrorID(int id)
Checks the error status of all of the images tracked by this media tracker with the specified identifier.

Parameters:
id - the identifier of the images to check
Returns:
true if any of the images with the specified identifier had an error during loading; false otherwise
See Also:
isErrorAny() sample code for java.awt.MediaTracker.isErrorAny() definition code for java.awt.MediaTracker.isErrorAny() , getErrorsID(int) sample code for java.awt.MediaTracker.getErrorsID(int) definition code for java.awt.MediaTracker.getErrorsID(int)

getErrorsID sample code for java.awt.MediaTracker.getErrorsID(int) definition code for java.awt.MediaTracker.getErrorsID(int)

public Object sample code for java.lang.Object definition code for java.lang.Object [] getErrorsID(int id)
Returns a list of media with the specified ID that have encountered an error.

Parameters:
id - the identifier of the images to check
Returns:
an array of media objects tracked by this media tracker with the specified identifier that have encountered an error, or null if there are none with errors
See Also:
isErrorID(int) sample code for java.awt.MediaTracker.isErrorID(int) definition code for java.awt.MediaTracker.isErrorID(int) , isErrorAny() sample code for java.awt.MediaTracker.isErrorAny() definition code for java.awt.MediaTracker.isErrorAny() , getErrorsAny() sample code for java.awt.MediaTracker.getErrorsAny() definition code for java.awt.MediaTracker.getErrorsAny()

waitForID sample code for java.awt.MediaTracker.waitForID(int) definition code for java.awt.MediaTracker.waitForID(int)

public void waitForID(int id)
               throws InterruptedException sample code for java.lang.InterruptedException definition code for java.lang.InterruptedException 
Starts loading all images tracked by this media tracker with the specified identifier. This method waits until all the images with the specified identifier have finished loading.

If there is an error while loading or scaling an image, then that image is considered to have finished loading. Use the isErrorAny and isErrorID methods to check for errors.

Parameters:
id - the identifier of the images to check
Throws:
InterruptedException sample code for java.lang.InterruptedException definition code for java.lang.InterruptedException - if another thread has interrupted this thread.
See Also:
waitForAll() sample code for java.awt.MediaTracker.waitForAll() definition code for java.awt.MediaTracker.waitForAll() , isErrorAny() sample code for java.awt.MediaTracker.isErrorAny() definition code for java.awt.MediaTracker.isErrorAny() , isErrorID(int) sample code for java.awt.MediaTracker.isErrorID(int) definition code for java.awt.MediaTracker.isErrorID(int)

waitForID sample code for java.awt.MediaTracker.waitForID(int, long) definition code for java.awt.MediaTracker.waitForID(int, long)

public boolean waitForID(int id,
                         long ms)
                  throws InterruptedException sample code for java.lang.InterruptedException definition code for java.lang.InterruptedException 
Starts loading all images tracked by this media tracker with the specified identifier. This method waits until all the images with the specified identifier have finished loading, or until the length of time specified in milliseconds by the ms argument has passed.

If there is an error while loading or scaling an image, then that image is considered to have finished loading. Use the statusID, isErrorID, and isErrorAny methods to check for errors.

Parameters:
id - the identifier of the images to check
ms - the length of time, in milliseconds, to wait for the loading to complete
Throws:
InterruptedException sample code for java.lang.InterruptedException definition code for java.lang.InterruptedException - if another thread has interrupted this thread.
See Also:
waitForAll() sample code for java.awt.MediaTracker.waitForAll() definition code for java.awt.MediaTracker.waitForAll() , waitForID(int) sample code for java.awt.MediaTracker.waitForID(int) definition code for java.awt.MediaTracker.waitForID(int) , statusID(int, boolean) sample code for java.awt.MediaTracker.statusID(int, boolean) definition code for java.awt.MediaTracker.statusID(int, boolean) , isErrorAny() sample code for java.awt.MediaTracker.isErrorAny() definition code for java.awt.MediaTracker.isErrorAny() , isErrorID(int) sample code for java.awt.MediaTracker.isErrorID(int) definition code for java.awt.MediaTracker.isErrorID(int)

statusID sample code for java.awt.MediaTracker.statusID(int, boolean) definition code for java.awt.MediaTracker.statusID(int, boolean)

public int statusID(int id,
                    boolean load)
Calculates and returns the bitwise inclusive OR of the status of all media with the specified identifier that are tracked by this media tracker.

Possible flags defined by the MediaTracker class are LOADING, ABORTED, ERRORED, and COMPLETE. An image that hasn't started loading has zero as its status.

If the value of load is true, then this method starts loading any images that are not yet being loaded.

Parameters:
id - the identifier of the images to check
load - if true, start loading any images that are not yet being loaded
Returns:
the bitwise inclusive OR of the status of all of the media with the specified identifier that are being tracked
See Also:
statusAll(boolean) sample code for java.awt.MediaTracker.statusAll(boolean) definition code for java.awt.MediaTracker.statusAll(boolean) , LOADING sample code for java.awt.MediaTracker.LOADING definition code for java.awt.MediaTracker.LOADING , ABORTED sample code for java.awt.MediaTracker.ABORTED definition code for java.awt.MediaTracker.ABORTED , ERRORED sample code for java.awt.MediaTracker.ERRORED definition code for java.awt.MediaTracker.ERRORED , COMPLETE sample code for java.awt.MediaTracker.COMPLETE definition code for java.awt.MediaTracker.COMPLETE

removeImage sample code for java.awt.MediaTracker.removeImage(java.awt.Image) definition code for java.awt.MediaTracker.removeImage(java.awt.Image)

public void removeImage(Image sample code for java.awt.Image definition code for java.awt.Image  image)
Removes the specified image from this media tracker. All instances of the specified image are removed, regardless of scale or ID.

Parameters:
image - the image to be removed
Since:
JDK1.1
See Also:
removeImage(java.awt.Image, int) sample code for java.awt.MediaTracker.removeImage(java.awt.Image, int) definition code for java.awt.MediaTracker.removeImage(java.awt.Image, int) , removeImage(java.awt.Image, int, int, int) sample code for java.awt.MediaTracker.removeImage(java.awt.Image, int, int, int) definition code for java.awt.MediaTracker.removeImage(java.awt.Image, int, int, int)

removeImage sample code for java.awt.MediaTracker.removeImage(java.awt.Image, int) definition code for java.awt.MediaTracker.removeImage(java.awt.Image, int)

public void removeImage(Image sample code for java.awt.Image definition code for java.awt.Image  image,
                        int id)
Removes the specified image from the specified tracking ID of this media tracker. All instances of Image being tracked under the specified ID are removed regardless of scale.

Parameters:
image - the image to be removed
id - the tracking ID frrom which to remove the image
Since:
JDK1.1
See Also:
removeImage(java.awt.Image) sample code for java.awt.MediaTracker.removeImage(java.awt.Image) definition code for java.awt.MediaTracker.removeImage(java.awt.Image) , removeImage(java.awt.Image, int, int, int) sample code for java.awt.MediaTracker.removeImage(java.awt.Image, int, int, int) definition code for java.awt.MediaTracker.removeImage(java.awt.Image, int, int, int)

removeImage sample code for java.awt.MediaTracker.removeImage(java.awt.Image, int, int, int) definition code for java.awt.MediaTracker.removeImage(java.awt.Image, int, int, int)

public void removeImage(Image sample code for java.awt.Image definition code for java.awt.Image  image,
                        int id,
                        int width,
                        int height)
Removes the specified image with the specified width, height, and ID from this media tracker. Only the specified instance (with any duplicates) is removed.

Parameters:
image - the image to be removed
id - the tracking ID from which to remove the image
width - the width to remove (-1 for unscaled)
height - the height to remove (-1 for unscaled)
Since:
JDK1.1
See Also:
removeImage(java.awt.Image) sample code for java.awt.MediaTracker.removeImage(java.awt.Image) definition code for java.awt.MediaTracker.removeImage(java.awt.Image) , removeImage(java.awt.Image, int) sample code for java.awt.MediaTracker.removeImage(java.awt.Image, int) definition code for java.awt.MediaTracker.removeImage(java.awt.Image, int)