|20-CS-694||Advanced Programming Techniques||Spring 2012|
The problem: I would like class U to inherit the click
service of class Aservicer but I also want to inherit
services from JPanel. No problem: I can create an object of
class Aservicer and use that object to invoke the methods of
Aservicer that I need.
The AServicer class provides a click recording service - an object of this class provides a panel and records the position of mouse clicks in the panel. The service provided is to return the coordinates of the last click in the panel.
||The problem: now the problem is to have the Aservicer class report the mouse clicks as they happen. This requires a reference to the U class object from the Aservicer class.|
We look for more generality. The problem: First, consider the
possibility of expanding what is sent
to mouseClickedInAservicerPanel(). Develop an Event
class called AnEvent and send an object containing
coordinates plus anything else to mouseClickedInAservicePanel().
Changed the argument of mouseClickedInAservicePanel() to an AnEvent object
||Finally, it is required to implement an interface to guarantee that mouseClickedInAservicePanel will be available for the service provider to use.|