| 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 | 40 | public MyTreeTableCellEditor(JTree tree, JTable table) { |
| 34 | 40 | this.tree = tree; |
| 35 | 40 | this.table = table; |
| 36 | 40 | } |
| 37 | |
|
| 38 | |
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int r, int c) { |
| 39 | 0 | return tree; |
| 40 | |
} |
| 41 | |
|
| 42 | |
public boolean isCellEditable(EventObject e) { |
| 43 | 0 | if (e instanceof MouseEvent) { |
| 44 | 0 | int colunm1 = 0; |
| 45 | 0 | MouseEvent me = (MouseEvent) e; |
| 46 | 0 | int doubleClick = 2; |
| 47 | 0 | MouseEvent newME = new MouseEvent(tree, me.getID(), me.getWhen(), me.getModifiers(), me.getX() |
| 48 | 0 | - table.getCellRect(0, colunm1, true).x, me.getY(), doubleClick, me.isPopupTrigger()); |
| 49 | 0 | tree.dispatchEvent(newME); |
| 50 | |
} |
| 51 | 0 | return false; |
| 52 | |
} |
| 53 | |
|
| 54 | |
|
| 55 | |
public Object getCellEditorValue() { |
| 56 | 0 | return null; |
| 57 | |
} |
| 58 | |
|
| 59 | |
} |