confused... applet won't run.
My applet runs fine in Eclipse, and previous applets I made work fine as well, but for some reason this one won't. Here is my code:
package q5;
import javax.swing.JApplet;
import java.awt.*;
/**
* @author your name here
*
*/
public class BusinessCard extends JApplet {
Font textFont, textFont2, textFont3;
public void init() {
setSize(600, 400);
textFont = new Font("TimesNewRoman", Font.ITALIC + Font.BOLD, 40);
textFont2 = new Font("TimesNewRoman", Font.PLAIN + Font.BOLD, 20);
textFont3 = new Font("TimesNewRoman", Font.PLAIN, 14);
}
public void paint(Graphics g) {
int x, y; // x and y coordinates of upper left-corner of each shape
int width, height; // width and height of each shape
setBackground(Color.white);
g.drawRect(50, 50, 500, 300);
g.setColor(Color.cyan);
g.fillRect(51, 51, 499, 79);
g.setColor(Color.red);
g.fillOval(400, 65, 60, 50);
g.setColor(Color.green);
g.fillOval(430, 65, 60, 50);
g.setColor(Color.blue);
g.fillOval(460, 65, 60, 50);
g.setColor(Color.black);
g.setFont(textFont);
g.drawString("Sage Styling", 100, 102);
etc...
}
}
and then the HTML file is:
<html>
<applet code="BusinessCard.class" width=800 height=500>
</applet>
</html>
this is the error I get when I try to load the applet:
java.lang.NoClassDefFoundError: BusinessCard (wrong name: q5/BusinessCard)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknow n Source)
at sun.plugin2.applet.Applet2ClassLoader.findClass(Un known Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unk nown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unk nown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.lang.NoClassDefFoundError: BusinessCard (wrong name: q5/BusinessCard)
any help would be greatly appreciated :) All files are in the same folder, and when I double click the HTML file I get this error. Nothing is misspelt, I'm unsure what to do :/