Valhalla Legends Forums Archive | Java Programming | Implementing Interfaces

AuthorMessageTime
JoeTheOdd
I posted this exact post at x86, but I figured I'd post it here incase someone doesn't know there (or see it).

[hr]

In my free time in Comp Prog, I'm writing an IRC client, but that's beside the point (mostly). I've written a EventCallbacks interface and implemented it in both SwingUI and ConsoleUI. I want to be able to pass the reference to the UI to the Connection class so that it can fire their callbacks. Do I just pass it as [tt]EventCallback UI[/tt] or as a java.lang.Object, or what?

EDIT -
I may not be able to read this in the morning, so could you drop the answer in an email to wlafrance@baraboo.k12.wi.us as well, please? (It's for class, so eh?)
Thanks.
April 5, 2006, 3:57 AM
Myndfyr
EventCallbacks.  That's the point of having interfaces.
April 5, 2006, 6:05 AM
JoeTheOdd
I know, but I was asking how to pass it. Thanks Myndy.
April 5, 2006, 12:07 PM
Myndfyr
[quote author=J link=topic=14696.msg149854#msg149854 date=1144238822]
I know, but I was asking how to pass it. Thanks Myndy.
[/quote]

That's the point of having interfaces.  You implement interfaces so that you can treat objects as the interfaces they implement.  You don't need to typecast, and you get the benefits of early binding.
April 5, 2006, 4:19 PM
JoeTheOdd
Ok, I got it implemented and compiled and everything. Thanks guys.
April 5, 2006, 7:17 PM

Search