Class Bouncer

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----java.applet.Applet
                                   |
                                   +----Bouncer

public class Bouncer
extends Applet
implements Runnable
Controlling class to simulate a ball bouncing


Variable Index

 o ball

Constructor Index

 o Bouncer()

Method Index

 o getDimension()
Accessor function just returns the width and height as a Dimension
 o getHeight()
Accessor function just returns the height of the applet
 o getWidth()
Accessor function just returns the width of the applet
 o init()
Initialize the application.
 o main(String[])
main just builds our Bouncer applet, and displays the applet in a frame that we resize to be the size of the bouncer applet, then starts the applet.
 o mouseDown(Event, int, int)
Called when the mouse goes down. Deprecated.
 o mouseDrag(Event, int, int)
Reset the ball to this position as the user drags it around. Deprecated.
 o mouseUp(Event, int, int)
Called when the mouse goes up. Deprecated.
 o paint(Graphics)
Draw the scene
 o run()
Keep the ball(s) moving
 o start()
Create a thread and make this thread's target the applet.
 o stop()
Stop the ball from moving

Variables

 o ball
 public Ball ball

Constructors

 o Bouncer
 public Bouncer()

Methods

 o init
 public void init()
Initialize the application.

Overrides:
init in class Applet
 o start
 public void start()
Create a thread and make this thread's target the applet.

Overrides:
start in class Applet
 o run
 public void run()
Keep the ball(s) moving

 o stop
 public void stop()
Stop the ball from moving

Overrides:
stop in class Applet
 o paint
 public void paint(Graphics g)
Draw the scene

Overrides:
paint in class Container
 o getWidth
 public int getWidth()
Accessor function just returns the width of the applet

 o getHeight
 public int getHeight()
Accessor function just returns the height of the applet

 o getDimension
 public Dimension getDimension()
Accessor function just returns the width and height as a Dimension

 o mouseDrag
 public boolean mouseDrag(Event e,
                          int x,
                          int y)
Note: mouseDrag() is deprecated.

Reset the ball to this position as the user drags it around.

Overrides:
mouseDrag in class Component
 o mouseDown
 public boolean mouseDown(Event e,
                          int x,
                          int y)
Note: mouseDown() is deprecated.

Called when the mouse goes down. Stop moving

Overrides:
mouseDown in class Component
 o mouseUp
 public boolean mouseUp(Event e,
                        int x,
                        int y)
Note: mouseUp() is deprecated.

Called when the mouse goes up. Start moving again.

Overrides:
mouseUp in class Component
 o main
 public static void main(String args[])
main just builds our Bouncer applet, and displays the applet in a frame that we resize to be the size of the bouncer applet, then starts the applet. By providing this main method, we can invoke the applet by simply running "java Bouncer" (when Bouncer.class is in our $CLASSPATH). Without this main method, we'd have to use "appletviewer Bouncer.html" to run the applet. Bouncer.html: