i am trying to load images for an applet using imageicon but i found out that it doesnt work so i was wondering if there is other way to load em. by the way i am trying to load them in another class that is not the main one. this is the code:
i am using an imageicon to load an image and store it in an array of images since i cant use getDocumentBase() for a reason that i do not know. in the appletviewer works fine but when i try to see it in a webpage it doesnt show any of the images . can someone suggest me what to do?
import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import javax.swing.ImageIcon;
public class Map {
MainGame GameMode;
public Image MapArray[]=new Image[1000];
public ImageIcon img;
public int NumberOfImages;
public int Pause;
public int p;
File file[]=new File[1000];
boolean exists[]=new boolean[1000];
public int IndexRight[]=new int[1000];
TimerDemo t;
Map(MainGame GameMode){
this.GameMode=GameMode;
t=new TimerDemo(GameMode);
}
public void LoadMap(String Directory,String Ext,int NumberOfImages,int Pause){
this.NumberOfImages=NumberOfImages;
this.Pause=Pause;
for(int i=0;i<NumberOfImages;i++){
if(i<=8){
img=new ImageIcon(Directory+"00"+(i+1)+Ext);
}else if(i>=9 && i<=98){
img=new ImageIcon(Directory+"" +
"0"+(i+1)+Ext);
}else{
img=new ImageIcon(Directory+(i+1)+Ext);
}
MapArray[i]=img.getImage();
}
}
public Image ReturnMapIndex(){
Image imaging=MapArray[GameMode.MapIndex];
if(GameMode.UP){
if(p>Pause){
p=0;
GameMode.MapIndex++;
imaging=MapArray[GameMode.MapIndex];
}else{
p++;
}
}
if(GameMode.DOWN){
if(p>Pause){
p=0;
if(GameMode.MapIndex==0){
}else{
GameMode.MapIndex--;
}
imaging=MapArray[GameMode.MapIndex];
}else{
p++;
}
}
return imaging;
}
public void DrawMap(Graphics g){
g.drawImage(ReturnMapIndex(),1,1,null);
if(GameMode.ZOMBIE.Zposition==2){
t.start();
t.Draw(g);
}
}
}
thanks in advance.