|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
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 aComponentcan act as a "Drop Target" and as a "Drag Source." Here's a snapshot of this example:The example uses JList, but any otherComponentcould easily replaceJList. All you would have to do is revise implementations of theDNDComponentInterfacemethods.About the files
DNDList.java: the specialized
JListwhich can behave as aDropTargetand as aDragSource.DNDComponentInterface.java: the interface that all components must implement to add/remove elements to itself and to detect when a drop/drag occurs.
TestDND.java: the tester for this class.
Running this example
To run this example, do the following using JDK 1.2:
javac DNDList.javajavac DNDComponentInterface.javajavac TestDND.javajava TestDNDAbout the Author
Sheetal Gupta is a Senior Consultant with Ernst and Young's Java Service Line, based in New York.
|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2002 Sun Microsystems, Inc. All rights reserved.