View Javadoc
1   package wjhk.jupload2.gui.filepanel.treeview;
2   
3   import javax.swing.ListSelectionModel;
4   import javax.swing.event.ListSelectionEvent;
5   import javax.swing.event.ListSelectionListener;
6   import javax.swing.tree.DefaultTreeSelectionModel;
7   
8   /**
9    * This code is taken from the tutorial written by Jörn Hameister, <A
10   * HREF="http://www.hameister.org/JavaSwingTreeTable.html">available here</A>.<BR/>
11   * <BR/>
12   * Since the TreeTable composed of a JTree component and a JTable component, it must be ensured that in the selection of
13   * the tree or table always has a continuous line is highlighted. To ensure that you create a class
14   * MyTreeTableSelectionModel that extends the DefaultTreeSelectionModel. This selection model is later assigned to the
15   * JTree and JTable to.
16   * 
17   * @author Jörn Hameister
18   */
19  public class MyTreeTableSelectionModel extends DefaultTreeSelectionModel {
20  
21      private static final long serialVersionUID = 1L;
22  
23      public MyTreeTableSelectionModel() {
24          super();
25  
26          getListSelectionModel().addListSelectionListener(new ListSelectionListener() {
27              // @Override
28              public void valueChanged(ListSelectionEvent e) {
29                  System.out.print("[DEBUG] ListSelectionEvent: " + e + "\n");
30              }
31          });
32      }
33  
34      ListSelectionModel getListSelectionModel() {
35          return listSelectionModel;
36      }
37  }