View Javadoc
1   package edu.jiangxin.apktoolbox.swing.treetable;
2   
3   import java.awt.Dimension;
4   
5   import javax.swing.JTable;
6   
7   public class MyTreeTable extends JTable {
8   
9   
10      public MyTreeTable(MyAbstractTreeTableModel treeTableModel) {
11          super();
12  
13          // JTree erstellen.
14          MyTreeTableCellRenderer tree = new MyTreeTableCellRenderer(this, treeTableModel);
15  
16          // Modell setzen.
17          super.setModel(new MyTreeTableModelAdapter(treeTableModel, tree));
18  
19          // Gleichzeitiges Selektieren fuer Tree und Table.
20          MyTreeTableSelectionModel selectionModel = new MyTreeTableSelectionModel();
21          tree.setSelectionModel(selectionModel); //For the tree
22          setSelectionModel(selectionModel.getListSelectionModel()); //For the table
23  
24  
25          // Renderer fuer den Tree.
26          setDefaultRenderer(MyTreeTableModel.class, tree);
27          // Editor fuer die TreeTable
28          setDefaultEditor(MyTreeTableModel.class, new MyTreeTableCellEditor(tree, this));
29  
30          // Kein Grid anzeigen.
31          setShowGrid(false);
32  
33          // Keine Abstaende.
34          setIntercellSpacing(new Dimension(0, 0));
35  
36      }
37  }