Tuesday, April 21, 2009

Code for implementing the drop functionality in SWT tree

Below is a small snippet for code for implementing the drop functionality in SWT tree

int operations = DND.DROP_DEFAULT | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_MOVE;
DropTarget target = new DropTarget(tree, operations);
target.setTransfer(new Transfer[] { FileTransfer.getInstance() };);
target.addDropListener(new DropTargetAdapter() {

public void drop(DropTargetEvent event) {
File f = new File (event.item)
TreeItem item = new TreeItem (root, 0);
item.setText ("item");
item.setData (f);
}

No comments:

Post a Comment