Display display = new Display();
Shell shell = new Shell(display);
String word;
Label[] labelsRowOne;
Label[] labelsRowTwo;
Font font = new Font(display, "Arial", 18, SWT.BOLD);
public void setDragSource(final Label label) {
int operations = DND.DROP_MOVE;
final DragSource dragSource = new DragSource(label, operations);
Transfer[] formats = new Transfer[] { TextTransfer.getInstance()};
dragSource.setTransfer(formats);
dragSource.addDragListener(new DragSourceListener() {
public void dragStart(DragSourceEvent event) {
if (label.getText().length() == 0)
event.doit = false;
}
public void dragSetData(DragSourceEvent event) {
if (TextTransfer.getInstance().isSupportedType(event.dataType))
event.data = label.getText();
}
public void dragFinished(DragSourceEvent event) {
if (event.doit == true || event.detail == DND.DROP_MOVE) {
label.setText("");
}
}
});
label.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
dragSource.dispose();
}
});
}
public void setDropTarget(final Label label) {
int operations = DND.DROP_MOVE;
final DropTarget dropTarget = new DropTarget(label, operations);
Transfer[] formats = new Transfer[] { TextTransfer.getInstance()};
dropTarget.setTransfer(formats);
dropTarget.addDropListener(new DropTargetListener() {
public void dragEnter(DropTargetEvent event) {
if(label.getText().length() != 0)
event.detail = DND.DROP_NONE;
}
public void dragLeave(DropTargetEvent event) {
}
public void dragOperationChanged(DropTargetEvent event) {
}
public void dragOver(DropTargetEvent event) {
}
public void drop(DropTargetEvent event) {
if (TextTransfer
.getInstance()
.isSupportedType(event.currentDataType)) {
String text = (String) event.data;
label.setText(text);
check();
}
}
public void dropAccept(DropTargetEvent event) {
}
});