• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

event model without GUI

 
Chris Ben
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very helpful!!! It saves me a lot of time in searching the right resource.
Thanks a lot James.
Have a good weekend
Chris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic