The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Trail: Drag and Drop

A Drag and Drop Example by Sheetal Gupta

About the example

This simple example contains two lists from which a user can drag and drop items from one list to another. It illustrates the concept that a Component can act as a "Drop Target" and as a "Drag Source." Here's a snapshot of this example:

A snapshot of Sheetal Gupta's Drag and Drop example.

The example uses JList, but any other Component could easily replace JList. All you would have to do is revise implementations of the DNDComponentInterface methods.

About the files

Running this example

To run this example, do the following using JDK 1.2:
  1. javac DNDList.java
  2. javac DNDComponentInterface.java
  3. javac TestDND.java
  4. java TestDND

About the Author

Sheetal Gupta is a Senior Consultant with Ernst and Young's Java Service Line, based in New York.

Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Copyright 1995-2001 Sun Microsystems, Inc. All rights reserved.