next up previous
Next: Oh yeah? Prove it. Up: How to Use the Previous: Where's the beef?

But how do you use it?

So now we've got event objects and delivery objects. But how do they know about one another? In order to tell them of one another, you must ``bind'' the delivery to the event, with the Event.bind() method. Please follow along in implicitinvocation/CreateBindings.java for an example.

The Event.bind() method is generic - it's a method that exists whether there are any events created or not, and is a globally accessible method. In order to bind a delivery object to an event, therefore, it needs to know which event you want bound, and which delivery object you want it to use.

The actual parameters are two classes and a delivery object; the first parameter is the class of the event, the next parameter is the class of the recipient object, and the third class is the actual delivery object.

After all that, the events know which delivery objects they are associated with. The last step in hooking everything together is to register objects for delivery of events. This is done by using the Event.register() method, which takes two parameters - the class of the event to register for, and the object to whom to deliver the event. The delivery object you linked in previously will be used to actually deliver the event.

As a result of this setup, any class may be announced as an event, regardless of whether any component is listening for it or not.


next up previous
Next: Oh yeah? Prove it. Up: How to Use the Previous: Where's the beef?
Tom Conversion Service