Java Image Wait waitForImage(Image image)

Here you can find the source of waitForImage(Image image)

Description

wait For Image

License

Open Source License

Declaration

public static boolean waitForImage(Image image) 

Method Source Code


//package com.java2s;
/*//from   ww  w  . ja  v  a  2 s .  c o  m
 * @(#)ImageUtil.java 1.2 04/12/06
 *
 * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
 *
 * See the file "LICENSE.txt" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */

import java.awt.*;

public class Main {
    static Component component = new Component() {
    };
    static MediaTracker tracker = new MediaTracker(component);
    static int sid = 0;

    public static boolean waitForImage(Image image) {
        int id;
        synchronized (component) {
            id = sid++;
        }
        tracker.addImage(image, id);
        try {
            tracker.waitForID(id);
        } catch (InterruptedException e) {
            return false;
        }
        tracker.removeImage(image, id);
        return !tracker.isErrorID(id);
    }
}

Related

  1. waitFor(Image image)
  2. waitForImage(Image image)
  3. waitForImage(Image image)
  4. waitForImage(Image image, Component c)
  5. waitForImage(Image image, Component component)
  6. waitForImage(Image image, Component component)