home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Gallery
/
INTERGAL.bin
/
intergal
/
prgs
/
idv21
/
data.z
/
ImageTracker.java
< prev
next >
Wrap
Text File
|
1996-05-20
|
1KB
|
45 lines
// ImageTracker by Lars Gersmann' May 96
import java.awt.*;
import java.applet.Applet;
import java.awt.image.*;
class ImageTracker {
Image imgarray[] = null;
int pos = 0;
Applet applet = null;
MediaTracker tracker = null;
ImageTracker( Applet applet,String imagefile) {
this.applet = applet;
imgarray = new Image[8];
tracker = new MediaTracker( applet );
for(int i=0; i<8; i++) {
imgarray[i] = applet.getImage( applet.getDocumentBase(), "images/" + imagefile + (i+1) + ".jpg");
tracker.addImage( imgarray[i], i );
applet.showStatus( "Loading images ... please wait");
}
for(int i=0; i<8; i++) {
try {
tracker.waitForID(i);
} catch( InterruptedException e) {};
if( tracker.isErrorID(i) ) {
applet.showStatus( "Error loading image "+(i+1)+ "; Quitting.");
return;
}
applet.showStatus("Loading image "+(i+1)+" done.");
}
}
Image getImage(int pos) {
try {
return imgarray[pos];
} catch(ArrayIndexOutOfBoundsException e) {};
return null;
}
}