daily pastebin goal
30%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import org.eclipse.swt.widgets.*;
  2. import org.eclipse.swt.layout.*;
  3. import org.eclipse.swt.events.*;
  4. import org.eclipse.swt.dnd.*;
  5. import org.eclipse.swt.*;
  6.  
  7. public class TableListenerTest
  8. {
  9.     public static void main(String[] args) {
  10.         new TableListenerTest();
  11.     }
  12.    
  13.     public TableListenerTest () {
  14.         Shell shell = new Shell();
  15.         shell.setLayout(new FillLayout());
  16.        
  17.         Table table1 = new Table(shell, SWT.BORDER);
  18.         table1.addSelectionListener(new SelectionAdapter() {
  19.            public void widgetSelected(SelectionEvent event) {  
  20.                 System.out.println("event: selection");
  21.            }
  22.         });
  23.  
  24.         DragSource source = new DragSource(table1, DND.DROP_MOVE);
  25.         source.setTransfer(new Transfer[]{TextTransfer.getInstance()});
  26.         source.addDragListener(
  27.             new DragSourceListener() {
  28.                 public void dragStart(final DragSourceEvent event) {
  29.                     System.out.println("event: drag start");
  30.                 }
  31.                
  32.                 public void dragSetData(final DragSourceEvent event) {
  33.                     System.out.println("event: drag setData");
  34.                     event.data = "test";
  35.                 }
  36.                
  37.                 public void dragFinished(final DragSourceEvent event) {
  38.                     System.out.println("event: drag finished");
  39.                 }
  40.             });
  41.  
  42.         TableItem item = new TableItem(table1, SWT.NONE);
  43.         item.setText("drag me");
  44.        
  45.         Table table2 = new Table(shell, SWT.BORDER);
  46.        
  47.         DropTarget target = new DropTarget(table2, DND.DROP_MOVE);
  48.         target.setTransfer(new Transfer[]{TextTransfer.getInstance()});
  49.         target.addDropListener(
  50.             new DropTargetAdapter() {
  51.  
  52.                 public void drop(final DropTargetEvent event) {
  53.                     System.out.println("event: drop");
  54.                 }
  55.                
  56.                 public void dragEnter(final DropTargetEvent event) {
  57.                     System.out.println("event: drag enter");
  58.                 }
  59.                
  60.                 public void dragLeave(final DropTargetEvent event) {
  61.                     System.out.println("event: drag leave");
  62.                 }
  63.             });
  64.        
  65.         shell.open();
  66.         while (! shell.isDisposed())
  67.             if (! shell.getDisplay().readAndDispatch())
  68.                 shell.getDisplay().sleep();
  69.     }
  70.  
  71. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top