previous | start | next

The controller: 2

The controller manages the user interaction with the view.

If the view consist of multiple components, the controller may also consist of individual controllers - one for each component.

Controller code executes in response to events, e.g. user interaction with the view such as clicking on a canvas or a button, typing in a textbox component.

Controller code to handle an event is called an event handler.

Java controller's are typically created as instances of classes called listeners.

A JComponent maintains a list of EventListeners. So creating components that inherit from JComponent means that we can easily add controllers (i.e. listeners) to such components using the inherited methods for adding listeners.



previous | start | next