My Java applet (called NameInLights.class) does not display when I load my HTML page. The .class file definitely exists, and the other parts of my HTML display in their correct places on the page. Java is enabled in my browser and the applet works fine in the AppletViewer.
Here is my java code:
import java.util.Random;
import java.awt.*;
import java.applet.*;
public class NameInLights extends Applet {
private static final long serialVersionUID = 1L;
Random r = new Random();
String name = "Imulsion";//must keep my real name secret! :)
public void init(){
setSize(500,500);
}
public void paint(Graphics g){
g.setColor(new Color(r.nextInt(255),r.nextInt(255),r.nextInt(255)));
g.setFont(new Font("Comic sans ms",Font.BOLD,55));
g.drawString(name,125,250);
for(int loop=0;loop<500;loop++)
{
int red = r.nextInt(255);
int green = r.nextInt(255);
int blue = r.nextInt(255);
int x = r.nextInt(500);
int y = r.nextInt(500);
g.setColor(new Color(red,green,blue));
g.setFont(new Font("Times New Roman",Font.BOLD,24));
g.drawString("*",x,y);
}
}
}
And here is my HTML:
<html>
<body>
<p>
Here comes an awesome applet!
</p>
<br />
<br />
<applet code="NameInLights.class" width = 500 height = 500>
</applet>
<button type = "button" onclick = "window.location.reload()">
Change applet colours
</button>
<body>
<html>
Why does it not display?