I'm trying to test this applet example so I could use the same process for my real project, but every time I run my html page, it only displays a blank page in it. Heres my applet code written in Java:
ExampleEventHandling.java:
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
public class ExampleEventHandling extends Applet implements MouseListener{
StringBuffer strBuffer;
public void init() {
addMouseListener(this);
strBuffer = new StringBuffer();
addItem("initializing the apple ");
}
public void start() {
addItem("starting the applet ");
}
public void stop() {
addItem("stopping the applet ");
}
public void destroy() {
addItem("unloading the applet");
}
void addItem(String word) {
System.out.println(word);
strBuffer.append(word);
repaint();
}
public void paint(Graphics g) {
g.drawRect(0, 0,
getWidth() - 1,
getHeight() - 1);
g.drawString(strBuffer.toString(), 10, 20);
}
public void mouseEntered(MouseEvent event) {
}
public void mouseExited(MouseEvent event) {
}
public void mousePressed(MouseEvent event) {
}
public void mouseReleased(MouseEvent event) {
}
public void mouseClicked(MouseEvent event) {
addItem("mouse clicked! ");
}
}
Here's my html page:
<html>
<title>Event Handling</title>
<hr>
<applet code = "ExampleEventHandling.class"
width = "300" height = "300">
</applet>
<hr>
</html>
And I only executed a blank screen everytime. I got the .jar file of ExampleEventHandling.java packaged into my html project and everytime I run the html, it only shows a blank page. Can someone please help me? I don't know what else to do.