Here you can find the source of waitForImage(Image image)
Parameter | Description |
---|---|
image | The image to load. |
public static boolean waitForImage(Image image)
//package com.java2s; import java.awt.*; public class Main { /**//from w ww . java 2 s .co m * Required by waitForImage. */ private static final Component sComponent = new Component() { }; /** * Required by waitForImage. */ private static final MediaTracker sTracker = new MediaTracker(sComponent); /** * Required by waitForImage. */ private static int sID = 0; /** * Waits for an image to load fully. Returns true if everything goes well, * false on error. This method should support multi-threading (not tested).<br> * From <link>http://examples.oreilly.com/java2d/examples/Utilities.java</link><br> * In: Knudsen, J. 1999. Java 2D Graphics. O'Reilly. Page 198.<br> * @param image The image to load. * @return Returns true if everything goes well, false on error. */ public static boolean waitForImage(Image image) { int id; synchronized (sComponent) { id = sID++; } sTracker.addImage(image, id); try { sTracker.waitForID(id); } catch (InterruptedException ie) { return false; } if (sTracker.isErrorID(id)) { return false; } return true; } }