20-CS-694 Advanced Programming Techniques Spring 2012

Interfaces, Exceptions, Graphics, Animation, Threads, Reflection, Networking, RMI, JDBC, JNI

All lectures
Create a Servicer

    1.   Prog1.java

    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.

    2.   Prog2.java

    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.
    3.   Prog3.java

    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

    4.   Prog4.java

    Finally, it is required to implement an interface to guarantee that mouseClickedInAservicePanel will be available for the service provider to use.