Log in

View Full Version : Resolved Error with Java Applet



keyboard
08-26-2012, 01:05 AM
Hello All,
I have this Java code -


import java.applet.*;
import java.awt.*;
public class HelloWorld extends Applet
{
public void init()
{

}
// This method gets called when the applet is terminated
// That's when the user goes to another page or exits the browser.
public void stop()
{

}
// The standard method that you have to use to paint things on screen
// This overrides the empty Applet method, you can't called it "display" for example.

public void paint(Graphics g)
{
//method to draw text on screen
// String first, then x and y coordinate.
g.drawString("Hey hey hey",20,20);
g.drawString("Hellooow World",20,40);

}
}


(Which is compiled into HelloWorld.class)

and this html


<html>
<head>
<title>My First Java Applet</title>
</head>
<body>
Here's my first Java Applet:<br /><br />
<applet code="HelloWorld.class" width="300" height ="300">
</body>
</html>

However, when I load the html page, the java applet just says

Error. Click for details

When I click, it freezes the webpage (and the browser).
Any suggestions on what to do?

keyboard
09-20-2012, 09:26 AM
I figured it out; I hadn't enabled the java plugin when I reinstalled java...