Button vv = new Button("vvvv");
DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(vv, DnDConstants.ACTION_MOVE, new DragGestureListener(){
public void dragGestureRecognized(DragGestureEvent ee) {
ee.startDrag(DragSource.DefaultMoveDrop,Toolkit.getDefaultToolkit().getSystemClipboard().getContents(this),new DragSourceListener(){
public void dragDropEnd(DragSourceDropEvent dragsourcedropevent) {
System.out.println("vvdragDropEnd");
}
public void dragEnter(DragSourceDragEvent dragsourcedragevent) {
System.out.println("vvdragEnter");
}
public void dragExit(DragSourceEvent dragsourceevent) {
System.out.println("vvdragExit");
}
public void dragOver(DragSourceDragEvent dragsourcedragevent) {
System.out.println("vvdragOver");
}
public void dropActionChanged(DragSourceDragEvent dragsourcedragevent) {
System.out.println("vvdropActionChanged");
}});
}});
///////////////////////////////////////////
Button b= new Button("bbbbb");
new DropTarget(b,new DropTargetListener(){
public void dragEnter(DropTargetDragEvent droptargetdragevent) {
System.out.println("bbdragEnter");
}
public void dragExit(DropTargetEvent droptargetevent) {
System.out.println("bbdragExit");
}
public void dragOver(DropTargetDragEvent droptargetdragevent) {
System.out.println("bbdragOver");
try {
System.out.println(droptargetdragevent.getTransferable().getTransferData(DataFlavor.stringFlavor));
} catch (Exception e) {
e.printStackTrace();
}
}
public void drop(DropTargetDropEvent droptargetdropevent) {
System.out.println("bbdrop");
}
public void dropActionChanged(DropTargetDragEvent droptargetdragevent) {
System.out.println("bbdropActionChanged");
}});