The simplest java applet:
Java source: HelloWorld.java
HTML source: HelloWorld.html
A good applet takes its crucial values from HTML via
parameters, rather than hardwiring them. Here's a "Hello
World" which takes its string via a parameter, allowing
the HTML writer to customize it to display any text
desired:
Java source: Label1.java
HTML source: Label1.html
A good applet also allows minor parameters to
be customized, without forcing the HTML writer to specify
all of them every time. Also, it is more efficient to
process parameters just once at startup, rather than
every time the applet repaints. Here's a better
version of our applet:
Java source: Label2.java
HTML source: Label2.html
A good applet should also have a getParameterInfo method
summarizing the parameters it accepts. Our final version
adds this method plus parameters controlling background
and foreground color:
Java source: Label3.java
HTML source: Label3.html