|
BeachMap class extends directly from the
Applet class of java.Applet package. For more information on inheritance
hierarchy, visit the inheritance and collaboration page. To enable
itself to receive mouse events such as mouse clicks, it
implements the MouseListener and the MouseMotionListener
interfaces. MouseListener enables an object to receive mouse
click, mouse button pressed, mouse button released and few other
events; while the MouseMotionListener enables a component or the
event listener to detect mouse movement and a component has been
dragged. For further information on interfaces read the Inheritance
and Collaboration page.
These interfaces are essential to enable
the applet to perform its intended tasks. The code that handles
the mouse click event is placed in the mouseClicked() method which
is one of the five methods that must be defined by BeachMap. The
method will get all of the information regarding the event encapsulated
in an object called MouseEvent. The same principle applies to
the MouseMotionListener interface.
The figure above is the class diagram for
the applet, it shows the data members (on top of the line) and
the methods.
|