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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.