Java Image Wait waitForImage(Image image, Component component)

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

Description

Wait for an image to be ready

License

Open Source License

Return

boolean false if interrupted

Declaration

public static boolean waitForImage(Image image, Component component) 

Method Source Code

//package com.java2s;
/*/*from   w w w  . j  a va  2s. com*/
 * Copyright (C) 2004 by StreetFire Sound Labs
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * $Id: Util.java,v 1.7 2005/03/22 08:59:06 iain Exp $
 */

import java.awt.Component;

import java.awt.Image;
import java.awt.MediaTracker;

public class Main {
    /**
     *  Wait for an image to be ready
     *  @return boolean false if interrupted
     */
    public static boolean waitForImage(Image image, Component component) {
        MediaTracker mediaTracker = new MediaTracker(component);
        mediaTracker.addImage(image, 0);
        try {
            mediaTracker.waitForID(0);
        } catch (InterruptedException e) {
            return false;
        }
        return true;
    }
}

Related

  1. waitForImage(Image image)
  2. waitForImage(Image image)
  3. waitForImage(Image image)
  4. waitForImage(Image image, Component c)
  5. waitForImage(Image image, Component component)
  6. waitForImage(java.awt.Image image)
  7. waitForImage(java.awt.Image image)
  8. waitForImageData(Image image, Component comp)
  9. waitImage(Image i)