Mega Code Archive

 
Categories / Java Tutorial / SWT
 

Dragging and Dropping

The component you drag from is called the drag source. The component you drop on is called the drop target. SWT uses the DragSource class to represent drag sources. It offers a single constructor: DragSource(Control control, int style) DragSource Styles StyleDescription DND.DROP_NONENo drag or drop supported DND.DROP_COPYCopies the dragged data to the drop target DND.DROP_MOVEMoves the dragged data to the drop target DND.DROP_LINKCreates a link from the dragged data to the drop target Transfer objects convert data from its Java representation to the underlying platform's data representation, and vice versa. You can write your own Transfer classes. Or use FileTransfer to drag and drop files and TextTransfer to drag and drop text. To implement drop targets, SWT uses the DropTarget class. Its semantics mirror those of DragSource, and its lone constructor looks like this: DropTarget(Control control, int style)