Runtime error when using MediaTracker
Bjorn Sandberg
bs at netg.se
Tue Jan 19 07:07:16 PST 1999
I have a class which basically does this: (this is pseudo-code)
class GraphicsClass extends Canvas implements a lot of stuff {
Image img;
paint(Graphics g) {
if (needsupdate)
paintMyStuff();
g.drawImage(img,0,0,this);
}
paitMyStuff() {
MediaTracker tracker = new MediaTracker(this);
for (list of files) {
String str = new File(file).getAbsolutePath();
Image myImage = Toolkit.getDefaultToolkit().createImage(str);
tracker.addImage(myImage,1);
}
try { tracker.waitForAll(); } catch (InterruptedException e) { return; }
for (list of fetched images)
img.getGraphics().drawImage(img,x,y,this);
}
}
The problem I get is this:
First of all, none of the images show up.
Secondly, after the paint function ends, I get a runtime error:
java.lang.NullPointerException
at java/awt/MediaTrackerEntry.imageUpdate(286)
at java/awt/Image.stateChange(527)
at java/awt/Image.createFromFile(382)
at java/awt/Image$Initializer.startProduction(259)
at java/awt/Image$Initializer.run(191)
at java/lang/Thread.run(122)
The code works fine under JDK. I've tried replacing the original classpath
so it will use the Kaffe jar files, but the bug persists.
Kaffe version is 1.0.b1-1.
// Bjorn
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Bjorn Sandberg : Coder for hire : Part-time history nut : bs at netg.se
Diplomacy is the art of saying "nice doggy" until you can find a rock.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
More information about the kaffe
mailing list