Graphic Components > Table Component > Architecture of the Table Component > The Controller

The IlpTableController class represents the controller module of the MVC architecture. It can be attached to a table view by using the following code.

How to Attach a Controller to the Table View
IlpTableView tableView = new IlpTableView();
IlpTableController tableController = new IlpTableController();
tableView.setController(tableController);

Note that a controller is automatically attached to a table view when a table component is instantiated:

IlpTable tableComponent = new IlpTable();
IlpTableController controller = tableComponent.getController();
// tableComponent.getView().getController() == controller

When a controller is attached to a table view, the controller listens to the keyboard, mouse, and focus events that occur in the table and transfers them to the view interactor set to the controller.

Only one controller can be attached to a view at a time.

By default, the IlpTableController delegates event management to an IlpDefaultTableViewInteractor. However, you can specify another interactor by using the following code:

tableController.setViewInteractor(new MyInteractor());

For more details, see Interacting with the Graphic Components.

When an interactor receives mouse events from the controller, it tries to recognize the associated user gestures. For example, when it receives an event MOUSE_PRESSED followed by an event MOUSE_RELEASED, the interactor recognizes the gesture BUTTON1_CLICKED. The set of basic gestures recognized by an interactor is defined in the class IlpGesture.

Interactors allow you to associate behavior with user gestures by means of Java actions. You can also associate actions with keyboard events.

The IlpDefaultTableViewInteractor manages the events received from the controller in the following way:

The API of the IlpTableController also contains methods to sort the columns and filter the rows of the table view. See Table Component Services.