|
public void
init()
Applet loaded. public void
start()
Applet visible. public void
stop()
Applet occluded. public void
destroy()
Applet gone.
import java.applet.Applet public class sa extends Applet @Override public void init() System.out.println("in init()") @Override public void start() System.out.println("in start()") @Override public void stop() System.out.println("in stop()") @Override public void destroy() System.out.println("in destroy()")
init()
: Called once after the applet's been loaded. Set-up the
applet, acquire resources. Favor init()
over a default constructor.
start()
: Called when the applet becomes visible. Start doing
whatever the applet does (if anything).
stop()
: Called when the applet is no longer visible. Stop doing
whatever the applet does (if anything).
destroy()
: Called once when the applet's no longer needed. Release
resources acquired by the applet.
init()
, not a constructor,
start()
, not a main()
,
destroy()
, not a setDefaultCloseOperation()
,
setSize()
,
<title></title>
tag, not setTitle()
,
start()
and stop()
, not setVisible()
.
<html> <head> <title></title> </head> <body> This is a background <applet code = "sa.class" height = 0 width = 0> </applet> applet. </body></html>
code
: a URL to an applet class.
height
and width
: the applet real-estate height and width
in pixels (required).
<applet code = "sa.class" height = 0 width = 0> </applet>
$ls public-html dragon-curve.html DragonCurve.class DragonCurve$LineSegmentIterator.class DragonPanel$1.class DragonPanel.class DragonPanel$MouseHandler.class DragonPanel$KeyHandler.class $
codebase
attribute specifies an alternative directory for
class files.
codebase
is like a one-entry class path.
codebase
paths start at the HTML page directory.
<applet code = "DragonCurve.class" height = "500" width = "500" codebase = "../applets">
archive
attribute is a list of URLs for jar file containing
supporting class files.
<applet code = "EaglesWing.main" height = 500 width = 500 archive = "model.jar,view.jar,controller.jar">
<applet code = "show-quotes.class" height = 10 width = 10> <param name = "count" value = "10"/> <param name = "ibm" value = "123.23"/> <!- blah blah blah -> <param name = "red hat" value = "19.41"/> </applet>
getParameter()
method reads paramter values from the applet-tag
body.
<object codetype = "application/java" classid = "java:DragonCurve.class" height = 100 width = 100> </object>
about:plugins
url to check your browser's set of installed
plugins.
|
|
|
System.out
and
err
.
|
|
x
Java-console command.
<applet code = ... alt = "[Enable Java to see this applet.]" > [Install the Java plug-in to see this applet.] </applet>
.jnlp
extension, or
application/x-java-jnlp-file
MIME type.
javaws
(Java Web Start) is the externally implemented sandbox.
javaws
sandbox is a bit less constrained than the in-browser
sandbox.