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.
tableController.setViewInteractor(new MyInteractor());
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.
If the
event is a keyboard event, it checks whether an action has
been associated with this key. If so, it triggers the action.
If the event occurred on an
IlpGraphic object or on a representation
object, it delegates the event management to the
IlpObjectInteractor set to the
controller, if any.
It
checks whether the event corresponds to the display of a
pop-up menu. If so, and if a pop-up menu is set to this
interactor, it will display the pop-up menu and stop.
It
tries to recognize gestures from the event. When a gesture is
recognized, it triggers the action associated with this
gesture, if any.