Valhalla Legends Archive

Programming => General Programming => Java Programming => Topic started by: Joe[x86] on April 04, 2006, 10:57 PM

Title: Implementing Interfaces
Post by: Joe[x86] on April 04, 2006, 10:57 PM
I posted this exact post at x86, but I figured I'd post it here incase someone doesn't know there (or see it).




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 EventCallback UI 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 [email protected] as well, please? (It's for class, so eh?)
Thanks.
Title: Re: Implementing Interfaces
Post by: MyndFyre on April 05, 2006, 01:05 AM
EventCallbacks.  That's the point of having interfaces.
Title: Re: Implementing Interfaces
Post by: Joe[x86] on April 05, 2006, 07:07 AM
I know, but I was asking how to pass it. Thanks Myndy.
Title: Re: Implementing Interfaces
Post by: MyndFyre on April 05, 2006, 11:19 AM
Quote from: J on April 05, 2006, 07:07 AM
I know, but I was asking how to pass it. Thanks Myndy.

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.
Title: Re: Implementing Interfaces
Post by: Joe[x86] on April 05, 2006, 02:17 PM
Ok, I got it implemented and compiled and everything. Thanks guys.