|
Usage |
Top Previous Next |
To install a TreeTableHeader on a table, the TreeTableColumnModel that will contain the hierarchical column structure must first be created. Since, by assigning the tree header to the table, will make the table assign its 'flat' column model to the header, the TreeTableHeader's column model must be assigned to the table prior to assigning the header to the table. Otherwise, a ClassCastException will be thrown.
Example:
DefaultTreeTableColumnModel model = new DefaultTreeTableColumnModel();
//fill the model with some values as in this example
//create the TreeTableHeader
TreeTableHeader treeHeader = new TreeTableHeader(model);
//create the table
AdvancedJTable table = new AdvancedJTable();
//assign the 'tree' column model of the tree header - THIS IS IMPORTANT
table.setColumnModel(treeHeader.getColumnModel());
//assign the tree header to the table
table.setTableHeader(treeHeader);