1 package wjhk.jupload2.gui.filepanel.treeview; 2 3 import java.awt.Dimension; 4 5 import javax.swing.JTable; 6 7 /** 8 * This code is taken from the tutorial written by Jörn Hameister, <A 9 * HREF="http://www.hameister.org/JavaSwingTreeTable.html">available here</A>.<BR/> 10 * <BR/> 11 * This class is a generic class. It has not been adapted for JUpload. It's directly taken from Jörn Hameister tutorial<BR/> 12 * After the data model, the auxiliary components and the Main-Class are now missing is the actual TreeTable. For this 13 * purpose, the class is MyTreeTable created. This inherits from JTable . Since Java Multiple inheritance is not 14 * possible, the Tree component via an association in the class is MyTreeTableCellRenderer involved. The data model 15 * MyAbstractTreeTableModel is both the MyTreeTableCellRenderer (Tree) and on the Object MyTreeTableModelAdapter passed 16 * (Table). As a model, the class is MyTreeTableModelAdapter set. For simultaneously selecting Tree and Table is 17 * MyTreeTableSelectionModel for Tree and Table used. Then a default renderer for the tree and set a default editor for 18 * the table must be set. 19 * 20 * @author Jörn Hameister 21 */ 22 public class MyTreeTable extends JTable { 23 24 private static final long serialVersionUID = 1L; 25 26 private MyTreeTableCellRenderer tree; 27 28 @SuppressWarnings({ 29 "rawtypes", "unchecked" 30 }) 31 public MyTreeTable(MyTreeTableModel<? extends MyTreeNode> treeTableModel) { 32 super(); 33 34 // JTree erstellen. 35 tree = new MyTreeTableCellRenderer(this, treeTableModel); 36 37 // Modell setzen. 38 super.setModel(new MyTreeTableModelAdapter(treeTableModel, tree)); 39 40 // Gleichzeitiges Selektieren fuer Tree und Table. 41 MyTreeTableSelectionModel selectionModel = new MyTreeTableSelectionModel(); 42 tree.setSelectionModel(selectionModel); // For the tree 43 setSelectionModel(selectionModel.getListSelectionModel()); // For the table 44 45 // Renderer fuer den Tree. 46 setDefaultRenderer(MyTreeTableModel.class, tree); 47 // Editor fuer die TreeTable 48 setDefaultEditor(MyTreeTableModel.class, new MyTreeTableCellEditor(tree, this)); 49 50 // Kein Grid anzeigen. 51 setShowGrid(false); 52 53 // Keine Abstaende. 54 setIntercellSpacing(new Dimension(0, 0)); 55 } 56 57 /** 58 * @return the tree 59 */ 60 public MyTreeTableCellRenderer getTree() { 61 return tree; 62 } 63 64 }