What about the following: MyEventListenerInterface myEvent = new MyEventListenerInterface (); s1.addMyEventListener( myEvent );
Respects, JKid314159 http://existentialismagent001.blogspot.com/ --- On Wed, 7/15/09, srinivasrao dumpala <[email protected]> wrote: From: srinivasrao Subject: Re: [java programming] implementation parameter To: [email protected] Date: Wednesday, July 15, 2009, 2:27 PM Alex, You can create object with reference of interface and pass that reference to addMYEventListener method. it will work. MyEventListener myEvent = new MyEventListenerImpl(); s1.addMyEventListener( myEvent ); --- On Wed, 15/7/09, Alex <[email protected]> wrote: From: Alex <[email protected]> Subject: [java programming] implementation parameter To: "Free Java Programming Online Training Course by Sang Shin" <[email protected]> Date: Wednesday, 15 July, 2009, 9:00 PM Dear Java Programmer: The add.MyEventListener is excepting an implementation and not an interface. The purpose of the interface was to allow access from the outside. But clearly the implementation is being instantiated and then passed. I would have passed the interface as the implementation details would be hidden from outside. Please comment. public class MyEventExample { public static void main(String[] args) { // Create an event source MyEventSource s1 = new MyEventSource(); // Register an event listener to the event source s1.addMyEventListener( new MyEventListenerImpl() ); // Triger an event s1.triggerSomethingEvent("I won the lottery!"); // Trigger another event s1.triggerSomethingEvent("She said Yes!"); }//main Respects, JKid314159 http://existentialismagent001.blogspot.com/ Looking for local information? Find it on Yahoo! Local --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---
