I used a classPicLoader in order to load a picture.
Code:
class PicLoader
{
/**
* Retreives and loads an image
*
* @param file the picture filename
* @param component the component that will show the picture (needed for the mediatracker)
*/
public static Image get(String file, Component component)
{
Image pic = Toolkit.getDefaultToolkit().getImage(component.getClass().getResource("/" + file));
MediaTracker tracker = new MediaTracker(component);
tracker.addImage(pic, 0);
try{ tracker.waitForAll(); }
catch(InterruptedException ie){}
return pic;
}
}
And from your GUI class you call this clas and give the filename as a parameter
Bookmarks