dragSource.addDragSourceMotionListener(new DragSourceMotionListener() {
public void dragMouseMoved(DragSourceDragEvent dge) {
// TODO 自动生成方法存根
DragSourceContext dsc = dge.getDragSourceContext();
//拖拽过程中依据鼠标位置改变图标
Point pt = getMousePosition();
if (pt == null)
return;
TreePath tp = getPathForLocation(pt.x, pt.y);
java.awt.Cursor cursor = null;
if (tp != null) {
setSelectionPath(tp);
cursor = DragSource.DefaultCopyDrop;
}else {
setSelectionPath(null);
cursor = DragSource.DefaultCopyNoDrop;
}
dsc.setCursor(cursor);
}
});
}
public void dragMouseMoved(DragSourceDragEvent dge) {
// TODO 自动生成方法存根
DragSourceContext dsc = dge.getDragSourceContext();
//拖拽过程中依据鼠标位置改变图标
Point pt = getMousePosition();
if (pt == null)
return;
TreePath tp = getPathForLocation(pt.x, pt.y);
java.awt.Cursor cursor = null;
if (tp != null) {
setSelectionPath(tp);
cursor = DragSource.DefaultCopyDrop;
}else {
setSelectionPath(null);
cursor = DragSource.DefaultCopyNoDrop;
}
dsc.setCursor(cursor);
}
});
}