Updated 15th Feb' 2002
Standard disclaimer |
---|
There is no copyright attached with the code available here. I have put this up to provide some information on issues I had a hard time resolving. The code has been put together as an example and in a hurry. You can use this code anyway you want at your own risk. Don't blame if weird things start happening to your machine. If you find any of this useful, drop me a mail :-). Please send suggestions / comments / flame to me |
This example shows how to
TransferHandler
class available with JDK 1.4. (TransferHandler
takes care of installing key stroke handlers to capture
ctrl-c/v/x to copy/paste/cut from your
JComponent
.) JComponent
to another. TransferHandler
. Transferable
object to encapsulate
underlying objects.
Issues still not addressed
JTable
you have
to place the cursor on some existing row.
What kind of data transfer does this program handle?
Going through each component -
MyTree
accepts data only from
MyTable
MyTable
is appended to existing data.
MyTable
accepts data only from
MyTree
MyTree
replaces the existing data in the
table.
MyText
accepts data from
MyTree
, MyTable
, or
any other source which can provide data as text or in the
stringFlavor
. MyText
also accepts file(s) dragged from Windows File explorer,
these files appear as lines of file names in the text area.
Source files:
Setup:
javac *.java
will
do just fine).
java Foo
.