In this chapter, we looked in detail at the drag-and-drop mechanism offered by the Java 2 platform and showed how to use it in conjunction with Swing components. We started out by explaining the architecture and showed how the responsibility for a drag-and-drop operation is divided between the drag source, the drop target, and the underlying operating system. We then looked in detail at how to implement fully functioning drop targets and drag sources that allow you to transfer files and text between Java applications or between a Java application and a program running on the native platform. One of the most important issues that the developer has to confront when adding this facility to a custom component or to an application is how to represent the data being transferred. We addressed this topic by providing a detailed discussion of the Java data transfer package, which was originally created to provide a cut-and-paste mechanism for JDK 1.1. Finally, we brought all the pieces together by building a complete implementation of a tree component that displays a representation of a file system and allows the user to move files and directories around by dragging and dropping the icons that SSSrepresent them in the tree.