I have an applet that is not initializing:
import javax.swing.*;
public class WordSearchApplet extends JApplet
{
public WordSearchApplet (int width, int height)
{
}
public void init ()
{
new WordSearchApplet (700, 800);
}
}
Here is the error I get.
load: WordSearchApplet can't be instantiated.
java.lang.InstantiationException: WordSearchApplet
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
When I change it so the constructor takes no parameters, it works:
import javax.swing.*;
public class WordSearchApplet extends JApplet
{
public WordSearchApplet ()
{
}
public void init ()
{
new WordSearchApplet ();
}
}
Here is my html file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Word Search Applet</title>
</head>
<body>
<applet code="WordSearchApplet" archive="WordSearchList.jar" name="Word Search" width="700" height="900" id="Word Search"></applet>
</body>
</html>
Can you not pass parameters from the init () function to the applet's constructor?