Example usage for java.awt MediaTracker statusID

List of usage examples for java.awt MediaTracker statusID

Introduction

In this page you can find the example usage for java.awt MediaTracker statusID.

Prototype

public int statusID(int id, boolean load) 

Source Link

Document

Calculates and returns the bitwise inclusive OR of the status of all media with the specified identifier that are tracked by this media tracker.

Usage

From source file:ImageFrame.java

/**
 * Set the image from a file./*from w w  w .  j av a 2  s.  co  m*/
 */
public void setImage(File file) throws IOException {
    // load the image
    Image image = getToolkit().getImage(file.getAbsolutePath());

    // wait for the image to entirely load
    MediaTracker tracker = new MediaTracker(this);
    tracker.addImage(image, 0);
    try {
        tracker.waitForID(0);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    if (tracker.statusID(0, true) != MediaTracker.COMPLETE) {
        throw new IOException("Could not load: " + file + " " + tracker.statusID(0, true));
    }

    setTitle(file.getName());
    setImage(image);
}