This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Event Handling  RSS feed

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everybody.
i am facing some problems in event handlig. please help me regarding event generation,listener and and action performed.
how the flow moves from event source to listener and then to corresponding action.

gautam
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At the first place you need to understand that with Java 2 , The event model has changed to Event Delegation model.
The model has got three diff. entities, One The Event, Event Source, Listener.
The Event Source (For Eg. Button) is an object in a awt, which will generate a event. Yes Event in Java are represented in the form of a object.
The Listener has to register with the Event Source in order to receive the notification of an event having occured. The registration can be done using Add.... Method available in the AWT object.
Also note that Java has provided Listener in a form of interface, hence to start with you did create a class and implement the interface in the class. The interface methods will receive the event object as a parameter in the methods.
Of Course there are more sophisticated ways of handling events, Like for eg. Adapters. But for beginners I think you need to start with implementing listener interfaces.
Regards
Tushar Kansara
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!