Chapter 4. Working with events
This chapter covers
Without events, the widgets and containers we’ve looked at are only good for decoration. This chapter focuses on how to configure these components to understand and respond to user actions. In particular, it describes the SWT/JFace framework that acquires these actions and translates them into software constructs called events. The process of using a toolset to generate, receive, and respond to these events is the toolset’s event model. Many books on GUIs leave the event model until later chapters, but we feel the subject’s importance demands an early introduction.
The first part of this chapter describes the SWT data structures that enable applications to process events. These include the event classes, which are created when a user carries out actions, and the listener interfaces, which receive event objects. By combining these appropriately, an application can provide multiple responses to nearly every form of event that can occur. However, SWT’s powerful event-processing mechanisms can make coding more complicated than it needs to be. For this reason, we need to examine how JFace simplifies the process.