I can't figure out why my java applet is not displaying, I have all of the files in the same folder, and I have java enabled on my browser. Here is the code
//java code
import java.applet.*;
import java.awt.*;
import javax.swing.*;
/**
* The HelloWorld class implements an applet that
* simply displays "Hello World!".
*/
public class HelloWorld extends Applet {
private static final long serialVersionUID = 1L;
public void init()
{
//Third thing - Change applet size (Also background color is included)
setSize(500, 500);
}
public void paint(Graphics g) {
g.setColor(Color.cyan);
g.fillRect(0, 0, 500, 500);
int x;
String s = "Hello World";
Dimension d = getSize();
FontMetrics fm = g.getFontMetrics();
x = d.width/2 - fm.stringWidth(s)/2;
g.setColor(Color.black);
g.drawString(s, x, 100);
String s2 = "My name is Jeremy Spence";
Dimension d2 = getSize();
FontMetrics fm2 = g.getFontMetrics();
x = d2.width/2 - fm2.stringWidth(s)/2;
g.drawString(s2, x, 150);
String input = JOptionPane.showInputDialog("Number 1: ");
double num1 = Double.parseDouble(input);
input = JOptionPane.showInputDialog("Number 2: ");
double num2 = Double.parseDouble(input);
input = JOptionPane.showInputDialog("Number 3 ");
double num3 = Double.parseDouble(input);
double average = (num1 + num2 + num3)/3;
String s3 = "The average is: " + average;
Dimension d3 = getSize();
FontMetrics fm3 = g.getFontMetrics();
x = d3.width/2 - fm3.stringWidth(s)/2;
g.drawString(s3, x, 200);
}
}
//html code
<html>
<head>
<title>Jeremy Spence Applet</Title>
</head>
<body>
<applet Code="HelloWorld.class" width=200 Height=100></applet>
</body>
</html>