i try to display a random images on the applet using array to store all the pictures name.
what's wrong with the code?
package test;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Applet extends java.applet.Applet
{
Image thisFlag;
String images[]= {"0.gif", "1.gif"};
public void init()
{
int value;
value=(int)(java.lang.Math.random()*images.length);
thisFlag = getImage(getCodeBase(), images[value]);
}
public void paint(Graphics g)
{
g.drawImage(thisFlag,20,20,this);
}
}


Reply With Quote


Bookmarks