Bookmark utility part 1
Drag & Drop in
For the next weeks or months we will try do develop a bookmark utility.
We will start by looking at the drag and drop features in the java.awt.dnd
package.
|
If you are unfamiliar with the D&D package, please take some time
to browse through the classes and see what is there. Do not get me wrong;
you should not memorize the methods, just look quickly through the classes
of this package.
Hint: If you have not downloaded the Java API Documentation,
now is the time to do so. See Getting started section
for instructions.
|
|
Now you will try to make a small drag and drop test program. When you
select a piece of text from and external program, drag it and drop it over
your application, the text should appear in your application. For this
you could use a GUI component of your choice, for example JTextField or
JTextPane.
Hint:
DropTargetListener
,
DropTargetDropEvent.acceptDrop(...), java.awt.datatransfer.DataFlavor
and java.awt.datatransfer.Transferable
DragAndDropTest.java
|
|
|