1 32 33 package it.businesslogic.ireport.gui; 34 import java.awt.dnd.*; 35 import it.businesslogic.ireport.*; 36 import it.businesslogic.ireport.gui.dnd.*; 37 import java.awt.datatransfer.*; 38 39 43 public class JDragTable extends javax.swing.JTable implements DragGestureListener, 44 DragSourceListener { 45 46 public JDragTable() { 47 48 DragSource dragSource = DragSource.getDefaultDragSource(); 49 50 dragSource.createDefaultDragGestureRecognizer( 53 this, DnDConstants.ACTION_COPY, this); } 57 58 public void dragGestureRecognized(DragGestureEvent e) { 59 61 TransferableObject to = new TransferableObject(this.getValueAt(this.getSelectedRow(), this.getSelectedColumn() )); 62 63 try{ 64 if (to != null) 65 e.startDrag(DragSource.DefaultCopyDrop , to); } catch (Exception ex) { 69 70 ex.printStackTrace(); 71 72 } 73 74 } 75 76 public void dragDropEnd(DragSourceDropEvent e) {} 77 public void dragEnter(DragSourceDragEvent e) {} 78 public void dragExit(DragSourceEvent e) {} 79 public void dragOver(DragSourceDragEvent e) {} 80 public void dropActionChanged(DragSourceDragEvent e) {} 81 82 } 83 | Popular Tags |