I've seen this code many times, but I cannot get it to work:
MediaTracker tracker;
tracker = new MediaTracker(this);
Image image = Toolkit.getDefaultToolkit().getImage("test.gif");
tracker.addImage(image, 0);
try{
tracker.waitForID(0);
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
but this works:
MediaTracker tracker;
tracker = new MediaTracker(this);
Image image = Toolkit.getDefaultToolkit().getImage("C:/path to image/test.gif");
tracker.addImage(image, 0);
try{
tracker.waitForID(0);
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
Why doesn't it load the gif when just a filename is present? I've got the image in the same directory as the .java file and as the .class file.
Thanks for any help,
Ryan