aspose file tools*
The moose likes Beginning Java and the fly likes Listener/Events Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Listener/Events" Watch "Listener/Events" New topic
Author

Listener/Events

Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

Is there a name for this java idiom:
Class Listener{
foo( FooEvent f ) { ... } //1
bar( BarEvent b ) { ... } //2
}
I've also seen //1 and //2 collapsed into one method
and FooEvent & BarEvent moved into an inheritance hierachy.
Does this have any relation to "JavaBean event delegation", something I've heard thrown around in discussions ?
Also is this any similar to the Observer design pattern?
Pho


Regards,

Pho
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

Hi Pho -
First let's call one out formally, so we can keep out terms clear:

where SomeEvent might then be defined:

These are examples of a listener and event object in an event-delegation model, and their intent is functionally similar to Observer/Observable, so you're right on both counts.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Listener/Events