1 package wjhk.jupload2.gui.filepanel.treeview;
2
3 import java.awt.Component;
4 import java.awt.event.MouseEvent;
5 import java.util.EventObject;
6
7 import javax.swing.AbstractCellEditor;
8 import javax.swing.JTable;
9 import javax.swing.JTree;
10 import javax.swing.table.TableCellEditor;
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 public class MyTreeTableCellEditor extends AbstractCellEditor implements TableCellEditor {
26
27 private static final long serialVersionUID = 1L;
28
29 private JTree tree;
30
31 private JTable table;
32
33 public MyTreeTableCellEditor(JTree tree, JTable table) {
34 this.tree = tree;
35 this.table = table;
36 }
37
38 public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int r, int c) {
39 return tree;
40 }
41
42 public boolean isCellEditable(EventObject e) {
43 if (e instanceof MouseEvent) {
44 int colunm1 = 0;
45 MouseEvent me = (MouseEvent) e;
46 int doubleClick = 2;
47 MouseEvent newME = new MouseEvent(tree, me.getID(), me.getWhen(), me.getModifiers(), me.getX()
48 - table.getCellRect(0, colunm1, true).x, me.getY(), doubleClick, me.isPopupTrigger());
49 tree.dispatchEvent(newME);
50 }
51 return false;
52 }
53
54
55 public Object getCellEditorValue() {
56 return null;
57 }
58
59 }