2 replies
by solrak29
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?
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) );
with
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.
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending