aspose file tools*
The moose likes Beginning Java and the fly likes event model without GUI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "event model without GUI" Watch "event model without GUI" New topic
Author

event model without GUI

Chris Ben
Ranch Hand

Joined: Jan 15, 2001
Posts: 135
Hi,
I think I have been always confused with this event topic.
In Java, whenever I touched event before, it is GUI related, as adding a listener and so on. However, if I want to build an event in a non-GUI program, for example, start a timer in a class to check time, which changing the content of a hashtable based on the msg it got from a network, the EVENT of the change this hashtable may trigger another action as updating another hashtable somewhere, which depends how the first hashtable get updated.
I know this example can be done without using any Event model, but just wondering how I can do it in Java (I can easily do it with the delegation concept in C#)? Is there any routine class build-in to help me do that?
Thanks a lot
Chris
James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403
One way to do this is using the Observer/Observable paradigm (see interface java.util.Observer and class java.util.Observable).
Anyway here is a good article to get you started.
Chris Ben
Ranch Hand

Joined: Jan 15, 2001
Posts: 135
Hi James,
Thank you very much!
It is definitely a great article for a jump start. If you or anyone have any other good resource about this topic, please also let me know (for some reasons, I did not find it in Java tutorial in Sun website :-( ).
Thanks again
Chris
James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403
Hi Chris,
This is another article from that same site, which has more of an introduction to it.
http://www.javaworld.com/javaworld/jw-10-1996/jw-10-howto.html
Also if you don't want to go down the Observer/Observable path, here is another article explaining writing custom events/listeners/handlers.
James.
[ April 19, 2002: Message edited by: james swan ]
Chris Ben
Ranch Hand

Joined: Jan 15, 2001
Posts: 135
Very helpful!!! It saves me a lot of time in searching the right resource.
Thanks a lot James.
Have a good weekend
Chris
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: event model without GUI