Start Search Contents Index Links About

Bookmark utility part 1

Drag & Drop in

2002 - Week 7 - Havard Rast Blok

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



site: Håvard Rast Blok
mail:
updated: 27 July 2007