Class Sticks
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----java.applet.Applet
|
+----Sticks
- public class Sticks
- extends Applet
- implements Runnable
This extension to the Applet class bounces lots of lines around.
The size of the box is specified by the 'width' and 'height'
values in the applet tag.
-
Sticks()
-
-
init()
-
Applet initialisation routine
-
run()
-
The main thread of execution.
-
start()
-
Called each time the browser displays the page.
-
stop()
-
Called each time the browser leaves the page.
Sticks
public Sticks()
init
public void init()
- Applet initialisation routine
- Overrides:
- init in class Applet
start
public void start()
- Called each time the browser displays the page.
For each thread we may have, check if there isn't one running.
Create one if necessary and and start it up.
- Overrides:
- start in class Applet
stop
public void stop()
- Called each time the browser leaves the page.
Junk any threads that may be running.
- Overrides:
- stop in class Applet
run
public void run()
- The main thread of execution.
While we have a running thread, update the display,
sleep for the specified time and go round again.
Note that we draw directly onto the Applet's display area
(obtained using the getGraphics() method). This is because
with lots of independent threads moving lines around, we
can't do the drawing in a single paint routine (which is
in fact called within a Java System thread).