IV. EventHandling

The GUI framework JControl/Vole provides mechanisms for an message based handling of events that are used by all interactive components. Programmers of JControl/Vole based applications just have to implement an ActionListener to be albe to react to user inputs. How to install an ActionListener onto a specific GUI component and process its ActionEvents, will be shown in the following sections.

Figure 1: Event Handling by JControl/Vole

Figure 1 outlines the principle of the transmission of messages by JControl/Vole: An event loop, which runs as a background thread, is automatically installed by the class Frame. This loop continuously queries the keyboard and triggers a KeyEvent if a key is pressed. The KeyEvent is transmitted to the user interfaces' Container framework, that now has to determine which GUI component has to be related to the KeyEvent. Finally, the event reaches the very GUI component that currently owns the input focus and will there be transformed into an ActionEvent.

An ActionEvent can only be triggered, if the application program installed an ActionListener onto the GUI component (by invoking {component}.setActionListener(ActionListener listener)). In that case, the method onActionEvent(ActionEvent event) of the according ActionListener will be invoked and the application program is able to react to messages from this GUI component.