I’m a bit confused from what I’ve heard Java doesn’t do events.
But I know that it does GUI events.
Am I missing something? Does java have an event handling mechanism?
I’m aware that I can implement a publisher subscriber pattern, but I’m looking for native support within Java.
I seem to remember something about Java Adding events in either Java 5 or 6 but I can’t remember where I heard this and I may be making it up.
Basically I’m wrapping a device in a java class the device throws events, and I’m looking for the most logical way of exposing this. I come mostly from a .Net Background and I’m looking for something like the events in .Net (C#)
Any help would be appreciated.
Advertisement
Answer
As you already stated, you can do the exact same thing with the publisher-subscriber/Observer pattern. It just requires a bit more legwork.
And no, Java does not have native support for events, like C# does with delegates.