Both the AWT and JFC event models could benefit from the delegate scheme. Bringing delegate s to pure Java code is currently not possible. However, creating something that behaves similar to a delegate is not too difficult. Consequently, I'll present classes that mimic the delegate keyword, allowing you to build a complex user interface with simpler event-handling code. Event Handling and AWT Each Java AWT and JFC GUI object sends various events.
Events often represent user actions, like pressing a key or clicking a mouse button.
Events also represent state changes in the application, such as the window closing or the window needing to be repainted. Event objects often represent specific areas of the application. For example, there are WindowEvent objects that represent events relating to the state of the current window. These methods dispatch events to an object of type java.util.EventListener . However, you can override any of these methods to handle a given event.