Copyright © 1998 Sita Ramakrishnan, Monash University All rights reserved

Light Views

HomeCase StudiesOO TheoryHelp

Light Views Icon


Case Studies

Introduction

Event Testing

Inheritance & Collaboration

State Chart Diagram (UML)

Demo Description

BeachMap Applet BeachParking Applet BeachInfo Applet BeachStatistic Applet Beaches & Parking

Quiz

Questionnaire

Beaches and Parking Case Study

BeachMap applet

Demonstrations:

The BeachMap applet is one of the four applets that makes the case study. In this section, it will be  discussed in  more detail than previously have been. The purpose is to give knowledge of the internal working mechanism of the applet.

To start off this page, the relation between the applet and the rest of the applets is discussed. Then followed by the information on the applet itself.

It is the first applet that the user can interact with in a sense that other applets will ignore any user inputs before a beach from the map is selected. BeachMap waits for mouse clicks on the map area. When it detects the mouse click, it will validate the coordinates, that is the x and y values where the click was detected. If these values matches the coordinates of one of the beaches, the BeachMap will ask BeachInfo applet to update itself.

BeachMap

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.

 

 


Funded by Committee of University Teaching And Staff Development (CUTSD) through DEETYA, 1998