Here you can find the source of waitForImage(Image image, Component component)
public static boolean waitForImage(Image image, Component component)
//package com.java2s; //License from project: Open Source License import java.awt.*; import java.util.Random; public class Main { public static boolean waitForImage(Image image, Component component) { try {//from ww w. j a va 2s. com MediaTracker mediaTracker = new MediaTracker(component); int i = new Random().nextInt(); mediaTracker.addImage(image, i); mediaTracker.waitForID(i); return true; } catch (InterruptedException e) { return false; } } }