18.3. Event Programming

If you have done Win32 GUI-based or Java Swing/AWT-based programming, you are probably familiar with event programming. If you have dabbled in JavaBeans, you are probably familiar with the concept of listeners listening to changes to a JavaBeans property, and you know how these listeners can be added or deleted dynamically. Listeners in Java are essentially classes whose methods get called when a particular event happens. An event is also a class that is generated by yet another class, called the source. Because everything in Java is modeled as a class, it is sometimes confusing to differentiate a listener (the event receiver) from the source (the event generator).

Whether in Java or C#, an event is a message sent by an ...

Get .NET for Java Developers: Migrating to C# now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.