KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > awt > dnd > DropTargetAdapter


1 /*
2  * @(#)DropTargetAdapter.java 1.7 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.awt.dnd;
9
10 /**
11  * An abstract adapter class for receiving drop target events. The methods in
12  * this class are empty. This class exists only as a convenience for creating
13  * listener objects.
14  * <p>
15  * Extend this class to create a <code>DropTargetEvent</code> listener
16  * and override the methods for the events of interest. (If you implement the
17  * <code>DropTargetListener</code> interface, you have to define all of
18  * the methods in it. This abstract class defines a null implementation for
19  * every method except <code>drop(DropTargetDropEvent)</code>, so you only have
20  * to define methods for events you care about.) You must provide an
21  * implementation for at least <code>drop(DropTargetDropEvent)</code>. This
22  * method cannot have a null implementation because its specification requires
23  * that you either accept or reject the drop, and, if accepted, indicate
24  * whether the drop was successful.
25  * <p>
26  * Create a listener object using the extended class and then register it with
27  * a <code>DropTarget</code>. When the drag enters, moves over, or exits
28  * the operable part of the drop site for that <code>DropTarget</code>, when
29  * the drop action changes, and when the drop occurs, the relevant method in
30  * the listener object is invoked, and the <code>DropTargetEvent</code> is
31  * passed to it.
32  * <p>
33  * The operable part of the drop site for the <code>DropTarget</code> is
34  * the part of the associated <code>Component</code>'s geometry that is not
35  * obscured by an overlapping top-level window or by another
36  * <code>Component</code> higher in the Z-order that has an associated active
37  * <code>DropTarget</code>.
38  * <p>
39  * During the drag, the data associated with the current drag operation can be
40  * retrieved by calling <code>getTransferable()</code> on
41  * <code>DropTargetDragEvent</code> instances passed to the listener's
42  * methods.
43  * <p>
44  * Note that <code>getTransferable()</code> on the
45  * <code>DropTargetDragEvent</code> instance should only be called within the
46  * respective listener's method and all the necessary data should be retrieved
47  * from the returned <code>Transferable</code> before that method returns.
48  *
49  * @see DropTargetEvent
50  * @see DropTargetListener
51  *
52  * @author David Mendenhall
53  * @version 1.7, 12/19/03
54  * @since 1.4
55  */

56 public abstract class DropTargetAdapter implements DropTargetListener JavaDoc {
57
58     /**
59      * Called while a drag operation is ongoing, when the mouse pointer enters
60      * the operable part of the drop site for the <code>DropTarget</code>
61      * registered with this listener.
62      *
63      * @param dtde the <code>DropTargetDragEvent</code>
64      */

65     public void dragEnter(DropTargetDragEvent JavaDoc dtde) {}
66
67     /**
68      * Called when a drag operation is ongoing, while the mouse pointer is still
69      * over the operable part of the drop site for the <code>DropTarget</code>
70      * registered with this listener.
71      *
72      * @param dtde the <code>DropTargetDragEvent</code>
73      */

74     public void dragOver(DropTargetDragEvent JavaDoc dtde) {}
75
76     /**
77      * Called if the user has modified
78      * the current drop gesture.
79      *
80      * @param dtde the <code>DropTargetDragEvent</code>
81      */

82     public void dropActionChanged(DropTargetDragEvent JavaDoc dtde) {}
83
84     /**
85      * Called while a drag operation is ongoing, when the mouse pointer has
86      * exited the operable part of the drop site for the
87      * <code>DropTarget</code> registered with this listener.
88      *
89      * @param dte the <code>DropTargetEvent</code>
90      */

91     public void dragExit(DropTargetEvent JavaDoc dte) {}
92 }
93
Popular Tags