Java BufferedImage Load loadImage(Image image)

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

Description

Loads the image, returning only when the image is loaded.

License

Open Source License

Parameter

Parameter Description
image the image

Declaration

private static void loadImage(Image image) 

Method Source Code

//package com.java2s;
/*/*from  w ww .ja  v  a2s  .  c  o  m*/
 * @(#)QuaquaUtilities.java  
 *
 * Copyright (c) 2003-2010 Werner Randelshofer, Immensee, Switzerland.
 * All rights reserved.
 *
 * You may not use, copy or modify this file, except in compliance with the
 * license agreement you entered into with Werner Randelshofer.
 * For details see accompanying license terms.
 */

import java.awt.*;

public class Main {
    private final static boolean DEBUG = false;

    /**
     * Loads the image, returning only when the image is loaded.
     * @param image the image
     */
    private static void loadImage(Image image) {
        Component component = new Component() {
        };
        MediaTracker tracker = new MediaTracker(component);
        synchronized (tracker) {
            int id = 0;

            tracker.addImage(image, id);
            try {
                tracker.waitForID(id, 0);
            } catch (InterruptedException e) {
                if (DEBUG) {
                    System.out.println("INTERRUPTED while loading Image");
                }
            }
            ///int loadStatus = tracker.statusID(id, false);
            tracker.removeImage(image, id);
        }
    }
}

Related

  1. loadImage(final String fileName)
  2. loadImage(final String iconFile)
  3. loadImage(final String imagePathname, final Class relatedClass)
  4. loadImage(final String path)
  5. loadImage(final URL urlToImage)
  6. loadImage(InputStream inputStream)
  7. loadImage(Object whoOrders, String name)
  8. loadImage(String classRelativeFile)
  9. loadImage(String filename)