|
ListTableMap |
Top Previous Next |
ListTableMap defines a TableModel that wraps around a ListTableModel, which is passed as an argument in the constructor. The methods of ListTableModel that are implemented are nothing more than calls to the respective methods of the underlying ListTableModel. In addition, events generated from the underlying ListTableModel are intercepted and sent to ListTableMap's table model listeners.
Other TableModels in the library extend ListTableMap, such as SortTableModel, FilterTableModel, TreeTableModel. All these ListTableMap's subclasses transform the underlying data in some way. By chaining multiple ListTableMaps, a cumulative transformation is achieved.
Example: Given the IDTableModel created in the previous section, make a sortable and filterable data model.
//create the chain of TableModels
IDTableModel originalModel = new IDTableModel();
FilterTableModel ftm = new FilterTableModel(originalModel);
SortTableModel stm = new SortTableModel(ftm);
//set the data model of the table to the last chained TableModel created.
JTable table = new JTable(stm);
OR
JTable table = new AdvancedJTable(stm);