Graphic Components > Table Component > Configuring the Table Component > Configuring the Table Component through the API

This section shows you how to configure a table component by coding. Filtering Rows later in this section goes into the details of the classes involved in the architecture of the table component.

The following example shows how to configure the table view (ilog.cpl.table.IlpTableView) through the API. See Table Component Services for programming details on the individual services.

How to Configure the Table View with the API
IlpTableView view = table.getView();
 
// Setting the selection mode
view.setSelectionMode(ListSelectionModel.SINGLE_OBJECT_SELECTION);
 
// Setting the table cell renderer
view.setDefaultRenderer(new MyTableCellRenderer());
 
// Setting the grid color
view.setGridColor(Color.blue);

The following example shows how to configure the table interactor through the API. For details, see Interacting with the Table View.

How to Configure the Table Interactor with the API
// Create the table, and retrieve the view interactor
IlpTable tableComponent = new IlpTable()
IlpViewInteractor viewInteractor = tableComponent.getViewInteractor();
// Create a Swing action
// We assume the MyAction class is defined elsewhere
Action myAction = new MyAction();
// Double-clicking the left mouse button will trigger myAction
viewInteractor.setGestureAction(IlpGesture.BUTTON1_DOUBLE_CLICKED,myAction);

The following example shows how to configure the table adapter through the API. See Table Component Services for programming details on the individual services.

How to Configure the Table Adapter with the API
IlpListAdapter adapter = table.getAdapter();
 
// Accepted class
// (it is the same as adapter.setAcceptedClass)
table.setAcceptedClass(IltNetworkElement.GetIlpClass());
 
// Setting the filter
IlpFilter myFilter = new MyFilter();
// (it is the same as adapter.setFilter(myFilter)
table.setFilter(myFilter);
 
// Table Row Factory
IlpTableRowFactory myRowFactory = new MyTableRowFactory();
adapter.setRepresentationObjectFactory(myRowFactory);