1 /*
2 * XNap - A P2P framework and client.
3 *
4 * See the file AUTHORS for copyright information.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20 package org.xnap.gui.table;
21
22 import java.awt.Component;
23 import java.awt.Point;
24 import java.awt.dnd.DnDConstants;
25 import java.awt.dnd.DragGestureListener;
26 import java.awt.dnd.DragSource;
27 import java.awt.dnd.MouseDragGestureRecognizer;
28 import java.awt.event.MouseEvent;
29
30 public class MouseDragAdapter extends MouseDragGestureRecognizer
31 {
32
33 //--- Constant(s) ---
34
35 //--- Data field(s) ---
36
37 private int x;
38 private int y;
39 private MouseEvent event;
40
41 //--- Constructor(s) ---
42
43 public MouseDragAdapter(DragSource ds, Component c, int actions,
44 DragGestureListener dgl)
45 {
46 super(ds, c, actions, dgl);
47 }
48
49 //--- Method(s) ---
50
51 public void mouseClicked(MouseEvent e)
52 {
53
54 }
55
56 public void mouseDragged(MouseEvent e)
57 {
58 if (e.getX() < x - 15) {
59 if (event != null) {
60 // FIX: this is an ugly work around, because dnd does not
61 // seem to work with jdk1.3.1 / linux with drag events
62 // it does not puke over MousePressed events though
63 appendEvent(event);
64 fireDragGestureRecognized(DnDConstants.ACTION_MOVE,
65 new Point(e.getX(), e.getY()));
66 }
67 }
68 }
69
70 public void mouseEntered(MouseEvent e)
71 {
72
73 }
74
75 public void mouseExited(MouseEvent e)
76 {
77
78 }
79
80 public void mouseMoved(MouseEvent e)
81 {
82
83 }
84
85 public void mousePressed(MouseEvent e)
86 {
87 x = e.getX();
88 y = e.getY();
89 event = e;
90 }
91
92 public void mouseReleased(MouseEvent e)
93 {
94 }
95
96 }