I am working on a homework assignment that is requiring me to create a basic applet that runs in a browser. I already know that the applets have been deprecated, so I know that this probably will not work with current browsers.
This is my Java code:
import java.applet.Applet;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JApplet;
import javax.swing.JLabel;
public class SimpleJavaApplet extends JApplet{
public void paint(Graphics g) {
g.drawString("Hello World!", 80, 80);
g.drawString("Blah!", 100, 100);
}
}
This is my HTML code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>A Short Test</title>
</head>
<body>
<title>Test Applet</title>
<applet code="SimpleJavaApplet.class" width = "200" height = "50">
</applet>
<h1>Test Test Test</h1>
</body>
</html>
What I was hoping would happen is that a browser would launch and it would show up with the HTML, but the only think I have been able to get to run is the AppletViewer. I am wondering if this is even possible anymore and if I should just let my professor know that.
Any ideas will be greatly appreciated.
Edit: Just to make things clearer, I am trying to run this code so it runs through a browser and not just the AppletViewer.