Java BufferedImage Load loadImage(String imageName, Component c)

Here you can find the source of loadImage(String imageName, Component c)

Description

Loads image

License

Open Source License

Parameter

Parameter Description
imageName the image to be loaded
c component where to place the image

Declaration


public static Image loadImage(String imageName, Component c) 

Method Source Code


//package com.java2s;
import java.awt.Component;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Toolkit;

public class Main {
    /**//from   w  ww . ja v a 2  s.c om
     *  Loads image
     *  @param imageName the image to be loaded
     *  @param c component where to place the image
     */
    //------------------------------------------------------------------------------
    public static Image loadImage(String imageName, Component c) {
        MediaTracker tracker = new MediaTracker(c);
        Image img = Toolkit.getDefaultToolkit().createImage(imageName);
        tracker.addImage(img, 0);

        try {
            tracker.waitForID(0);
        } catch (InterruptedException ie) {
            // ignore
        }
        return img;
    }
}

Related

  1. loadImage(String fileName, Component component)
  2. loadImage(String filePath)
  3. loadImage(String i, int x, int imageWidth, int imageHeight)
  4. loadImage(String image)
  5. loadImage(String imageName)
  6. loadImage(String path)
  7. loadImage(String path)
  8. loadImage(String resourceName)
  9. loadImage(String url)