Creating an applet is different than an application in that as
it appears inside of a webpage, it uses special classes
to dispaly information to the screen such as the
Graphics class instead of the System class used for applications.
More About Java Applets
- Every applet must import at least the java.awt.Graphics class, which
allows it to draw to the screen.
- Every applet class must be public and be a subclass of the class
Applet in the package java.applet (see examples in text).
- To display something to the screen a paint() method is needed.
- If you use the System.out.prinln() it will send its output
to a special text console window often called the "Javal Console"
in your browser. (you may have the option to show this or not).
- Other standard methods that take the place of main() in an
application are: init() which initializes the applet, start()
starts the applet running
- Notice that in the above examples what we will refer to as the "main"
applet class is passed to the applet HTML tag. This class must contain one
of the following mehtods: init(), start(), paint()
- The stop() method is called when the person leaves the webpage
containing the java code or hits the stop button when the page is loading. Unfotunately, this does not seem to be standard on each browser.
|