KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)MouseDragGestureRecognizer.java 1.14 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 import java.awt.Component JavaDoc;
11
12 import java.awt.event.MouseEvent JavaDoc;
13 import java.awt.event.MouseListener JavaDoc;
14 import java.awt.event.MouseMotionListener JavaDoc;
15
16 /**
17  * This abstract subclass of <code>DragGestureRecognizer</code>
18  * defines a <code>DragGestureRecognizer</code>
19  * for mouse-based gestures.
20  *
21  * Each platform implements its own concrete subclass of this class,
22  * available via the Toolkit.createDragGestureRecognizer() method,
23  * to encapsulate
24  * the recognition of the platform dependent mouse gesture(s) that initiate
25  * a Drag and Drop operation.
26  * <p>
27  * Mouse drag gesture recognizers should honor the
28  * drag gesture motion threshold, available through
29  * {@link DragSource#getDragThreshold}.
30  * A drag gesture should be recognized only when the distance
31  * in either the horizontal or vertical direction between
32  * the location of the latest mouse dragged event and the
33  * location of the corresponding mouse button pressed event
34  * is greater than the drag gesture motion threshold.
35  * <p>
36  * Drag gesture recognizers created with
37  * {@link DragSource#createDefaultDragGestureRecognizer}
38  * follow this convention.
39  *
40  * @author Laurence P. G. Cable
41  * @version 1.14
42  *
43  * @see java.awt.dnd.DragGestureListener
44  * @see java.awt.dnd.DragGestureEvent
45  * @see java.awt.dnd.DragSource
46  */

47
48 public abstract class MouseDragGestureRecognizer extends DragGestureRecognizer JavaDoc implements MouseListener JavaDoc, MouseMotionListener JavaDoc {
49
50     private static final long serialVersionUID = 6220099344182281120L;
51
52     /**
53      * Construct a new <code>MouseDragGestureRecognizer</code>
54      * given the <code>DragSource</code> for the
55      * <code>Component</code> c, the <code>Component</code>
56      * to observe, the action(s)
57      * permitted for this drag operation, and
58      * the <code>DragGestureListener</code> to
59      * notify when a drag gesture is detected.
60      * <P>
61      * @param ds The DragSource for the Component c
62      * @param c The Component to observe
63      * @param act The actions permitted for this Drag
64      * @param dgl The DragGestureListener to notify when a gesture is detected
65      *
66      */

67
68     protected MouseDragGestureRecognizer(DragSource JavaDoc ds, Component JavaDoc c, int act, DragGestureListener JavaDoc dgl) {
69     super(ds, c, act, dgl);
70     }
71
72     /**
73      * Construct a new <code>MouseDragGestureRecognizer</code>
74      * given the <code>DragSource</code> for
75      * the <code>Component</code> c,
76      * the <code>Component</code> to observe, and the action(s)
77      * permitted for this drag operation.
78      * <P>
79      * @param ds The DragSource for the Component c
80      * @param c The Component to observe
81      * @param act The actions permitted for this drag
82      */

83
84     protected MouseDragGestureRecognizer(DragSource JavaDoc ds, Component JavaDoc c, int act) {
85     this(ds, c, act, null);
86     }
87
88     /**
89      * Construct a new <code>MouseDragGestureRecognizer</code>
90      * given the <code>DragSource</code> for the
91      * <code>Component</code> c, and the
92      * <code>Component</code> to observe.
93      * <P>
94      * @param ds The DragSource for the Component c
95      * @param c The Component to observe
96      */

97
98     protected MouseDragGestureRecognizer(DragSource JavaDoc ds, Component JavaDoc c) {
99     this(ds, c, DnDConstants.ACTION_NONE);
100     }
101
102     /**
103      * Construct a new <code>MouseDragGestureRecognizer</code>
104      * given the <code>DragSource</code> for the <code>Component</code>.
105      * <P>
106      * @param ds The DragSource for the Component
107      */

108
109     protected MouseDragGestureRecognizer(DragSource JavaDoc ds) {
110     this(ds, null);
111     }
112
113     /**
114      * register this DragGestureRecognizer's Listeners with the Component
115      */

116
117     protected void registerListeners() {
118     component.addMouseListener(this);
119     component.addMouseMotionListener(this);
120     }
121
122     /**
123      * unregister this DragGestureRecognizer's Listeners with the Component
124      *
125      * subclasses must override this method
126      */

127
128
129     protected void unregisterListeners() {
130     component.removeMouseListener(this);
131     component.removeMouseMotionListener(this);
132     }
133
134     /**
135      * Invoked when the mouse has been clicked on a component.
136      * <P>
137      * @param e the <code>MouseEvent</code>
138      */

139
140     public void mouseClicked(MouseEvent JavaDoc e) { }
141
142     /**
143      * Invoked when a mouse button has been
144      * pressed on a <code>Component</code>.
145      * <P>
146      * @param e the <code>MouseEvent</code>
147      */

148
149     public void mousePressed(MouseEvent JavaDoc e) { }
150
151     /**
152      * Invoked when a mouse button has been released on a component.
153      * <P>
154      * @param e the <code>MouseEvent</code>
155      */

156
157     public void mouseReleased(MouseEvent JavaDoc e) { }
158
159     /**
160      * Invoked when the mouse enters a component.
161      * <P>
162      * @param e the <code>MouseEvent</code>
163      */

164
165     public void mouseEntered(MouseEvent JavaDoc e) { }
166
167     /**
168      * Invoked when the mouse exits a component.
169      * <P>
170      * @param e the <code>MouseEvent</code>
171      */

172
173     public void mouseExited(MouseEvent JavaDoc e) { }
174
175     /**
176      * Invoked when a mouse button is pressed on a component.
177      * <P>
178      * @param e the <code>MouseEvent</code>
179      */

180
181     public void mouseDragged(MouseEvent JavaDoc e) { }
182
183     /**
184      * Invoked when the mouse button has been moved on a component
185      * (with no buttons no down).
186      * <P>
187      * @param e the <code>MouseEvent</code>
188      */

189
190     public void mouseMoved(MouseEvent JavaDoc e) { }
191 }
192
193
194
Popular Tags