Chapter 14. Data Transfer
Data transfer is the generic
term for GUI mechanisms that allow an end user to transfer text or
other data within an application or between applications. The two
common data transfer metaphors are cut-and-paste and drag-and-drop.
Java's support for data transfer has evolved over
several releases:
In Java 1.1, the java.awt.datatransfer package
provided a data transfer infrastructure and support for the
cut-and-paste metaphor. Java 1.2 extended the data transfer infrastructure with the
java.awt.dnd package, and added support for
drag-and-drop. In Java 1.4, the javax.swing package introduces
the TransferHandler class, which simplifies the
data transfer infrastructure of previous releases and makes it easier
to provide simple drag-and-drop capabilities in a Swing application.
This chapter demonstrates how you can add support for cut-and-paste
and drag-and-drop to your AWT and Swing applications. It shows
how to use the Swing TransferHandler class for
simple cases, and how to use the underlying
DataFlavor class and the
Transferable interface to permit the transfer of
custom data types between applications.
|