Loading multiple images in applet
843807Apr 27 2004 — edited Apr 27 2004I am trying to create an applet that displays 8 images in a grid and up until now I have had no problems loading single images into the applet but I am having difficulty more than one. I thought I could just create multiple lines of the getImage method. It keeps telling me that an identifier is expected. I'm quite new to this so don't mock me.
import java.applet.*;
import java.awt.*;
import javax.swing.*;
public class clown extends Applet {
Image[] cln=new Image[8];
cln[0]=getImage(getDocumentBase(), "clown2.gif");
cln[1]=getImage(getDocumentBase(), "clown3.gif");
cln[2]=getImage(getDocumentBase(), "clown4.gif");
cln[3]=getImage(getDocumentBase(), "clown5.gif");
cln[4]=getImage(getDocumentBase(), "clown6.gif");
cln[5]=getImage(getDocumentBase(), "clown7.gif");
cln[6]=getImage(getDocumentBase(), "clown8.gif");
cln[7]=getImage(getDocumentBase(), "clown9.gif");
public void paint(Graphics g){
g.drawImage(cln[0], 0, 0, 0, 0, this);
g.drawImage(cln[0], 50, 10, 0, 0, this);
g.drawImage(cln[0], 100, 10, 0, 0, this);
g.drawImage(cln[0], 150, 10, 0, 0, this);
g.drawImage(cln[0], 200, 10, 0, 0, this);
g.drawImage(cln[0], 250, 10, 0, 0, this);
g.drawImage(cln[0], 300, 10, 0, 0, this);
g.drawImage(cln[0], 350, 10, 0, 0, this);
}
}