newbie image loading problem

im trying to load in some images half way through my game....but i dont want the applet to suddenly stop whilst this happens........here's my code at the mo, it doesnt seem to work....am i going along the right tracks, any advice would be great

i call the loadPic functions from the mousePressed function, and the main game thread should continue whilst this loads......but it doesnt

public Image loadPic(String path){

try{

temp_pic=getImage(getCodeBase(),path);

tracker.addImage(temp_pic, 0);

do{

repaint();

}while (tracker.checkID(0));

tracker.waitForID(0);

}catch (Exception e){ System.out.print("ERROR: " + path);}

loadscreen = createImage(temp_pic.getWidth(this),temp_pic.getHeight(this));

loadGraphics = loadscreen.getGraphics();

loadGraphics.drawImage(temp_pic,0,0,this);

repaint();

return loadscreen;

}

Message was edited by:

00

[1489 byte] By [00a] at [2007-10-3 1:08:44]
# 1
Assume there is variable for your image in class level. you should start a new thread(passing in the variable for image) to load the image.If you don't start a new thread, Java processes statement in sequentially and your applet looks freezing while loading image.
evilknighthka at 2007-7-14 18:05:34 > top of Java-index,Other Topics,Java Game Development...
# 2
i use advance media tracker, it gives you some useful features like calculating how much has been downloaded http://www.javaarchives.com/libraries.html
ptom98a at 2007-7-14 18:05:34 > top of Java-index,Other Topics,Java Game Development...