import java.awt.*; import java.applet.*; public class SimpleApplet extends Applet { public void init() { } public void paint( Graphics g) { } public void destroy() { } }there are three basic methods that should be provided
public void init()
public void paint( Graphics g)
public void destroy()
<APPLET>
tag:
<APPLET CODE=applet.class WIDTH=width HEIGHT=height> <PARAM NAME=name1 VALUE=value1> <PARAM NAME=name2 VALUE=value2> <PARAM NAME=name3 VALUE=value3> ... </APPLET>
However many sites disable java at the firewall so your applet may not appear to work in these cases. Most firewalls prevent java files from getting past them by looking for a ".class" extension. Both Netscape and Microsoft provide mechanisms to get around this.
<APPLET>
tag to read:
<APPLET archive=myarchive.zip CODE=applet.class WIDTH=width HEIGHT=height> <PARAM NAME=name1 VALUE=value1> <PARAM NAME=name2 VALUE=value2> <PARAM NAME=name3 VALUE=value3> ... </APPLET>
archive
attribute of the <APPLET> tag
. It
uses CAB
(Cabinet)
CAB
cabbase
<APPLET CODE=applet.class WIDTH=width HEIGHT=height> <PARAM NAME=name1 VALUE=value1> ... <PARAM NAME=cabbase VALUE=mycabinet.cab> ... </APPLET>
<PARAM>
<PARAM>
provides parameters that the
applet should read in its init()
method.
These generally control the applet's appearance and are not designed to be substitutes for a user interface.
public void init() { String my_arg1, myarg2, my_arg3, ...; my_arg1 = getParameter("name1"); my_arg2 = getParameter("name2"); my_arg3 = getParameter("name3"); ... }
public void init() { int value = default; my_arg = getParameter("name1"); if (my_arg == null){ try{ value = Integer.parseInt(my_arg); } catch (NumberFormatException e) { value = default; } } }
.