In several examples of our previous chapter, despite not being the focus of what we were trying to explain, we have shown how to deal with a few user events, such as the click of button, for instance. For every action a user takes, such as a mouse click, or a pressed key, an event is generated by the operating system. We can choose to handle what is considered relevant for the application being developed. To capture an event, it is necessary to add listeners to the code, that must be attached to an interface element, such as a shell, a composite, or a widget, present in a container.
The main process starts with the operating system event queue, that deals (record and list) with actions taken by an user. When an SWT application is being executed, the Display
class uses the readAndDispatch
method to monitor the messages from the operating system. It sorts through the relevant ones and sends them to the shell object, which is responsible for redirecting it to the associated widget. The...