Sun Java Solaris Communities My SDN Account Join SDN
 
Code sample

Code Samples from the Java Developers Almanac 2000

 

Code Samples Index

These code examples and other materials are subject to Sun Microsystems, Inc. Legal Terms

Making a Component a Drop Target

 public class DropTargetComponent extends JComponent 
   implements DropTargetListener {
     public DropTargetComponent() {
       new DropTarget(this, this);
         }
     public void dragEnter(DropTargetDragEvent evt) {
       // Called when the user is dragging and enters 
       // this drop target.
     }
     public void dragOver(DropTargetDragEvent evt) {
        // Called when the user is dragging and moves 
        // over this drop target.
     }
     public void dragExit(DropTargetEvent evt) {
        // Called when the user is dragging and 
        // leaves this drop target.
     }
     public void dropActionChanged(
       DropTargetDragEvent evt) {
         // Called when the user changes the drag 
         // action between copy or move.
     }
     public void drop(DropTargetDropEvent evt) {
        // Called when the user finishes or cancels 
        // the drag operation.
     }
 }
 

Examplets provided by permission of the publisher, Addision-Wesley, and Author Patrick Chan.
Order this book from Amazon