How Does Java Event Handling Work? Think Wedding Gifts

by Developer.com Staff

Java event handling is a core concept of the language and a vital mechanism for event-based programming. Learn an easy analogy for understanding how it works.

A good understanding of the Java event-handling mechanism is essential for any Java programmer. Event-based Java programming isn't limited just to GUI Swing programs; you also will find it in applications that use Java technologies such as servlets and message-driven beans.

In his JavaBoutique.com tutorial, Gurunath Kalamadi breaks down the event-handling concept with concise explanations and practical examples. He really brings the lesson home with a novel analogy for event handling: a group of friends deciding what gifts to bring to their friend's wedding.

Consider four friends: A, B, C and D. Suppose the event is A is getting married. A's friends, B, C and D, want to respond to this event. The response protocol is to attend the wedding and bring a gift for A. They all must adhere to the response protocol, but they are free to choose the gift they bring.

Read the entire tutorial at Java Boutique:
Java Programming Basics: Event Handling

This article was originally published on Saturday Sep 11th 2010
Mobile Site | Full Site