Web Development

General discussion


Simplify Event/Listener coding

By Mark W. Kaelin Editor ·
The Jan. 13, Java TechMail discusses the Notifier Class. Will you be able to simplify your Event/Listener coding using the Notifier Class?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

newbie question

by solrak29 In reply to Simplify Event/Listener c ...

I didnt' find this tip complete as I tried to test the code, but it seems that the ActionEvent object does not have a simple constructor as noted in the document. Thus, made this article incomplete and code unusable.....

Can you help?

Collapse -

Good catch

by bayard In reply to newbie question

That's true. You caught me being vague and hypothetical in my "Wouldn't it be nice".

java.awt.event.ActionEvent doesn't have a constructor which takes (Object), although the ultimate ancestor class java.util.EventObject does. Instead it has ActionEvent(Object, int, String), so replace

notifier.notify( new ActionEvent(this) );


notifier.notify( new ActionEvent(this, 0, "foo") );

The Event itself is relatively unimportant for the concept of Notifier as it just gets passed around, but the lack of compiling is a pain I admit. EventObject is the important class, ActionEvent is just an implementation.

Related Discussions

Related Forums