Here you can find the source of loadImage(String imageName, Component c)
Parameter | Description |
---|---|
imageName | the image to be loaded |
c | component where to place the image |
public static Image loadImage(String imageName, Component c)
//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; } }