@Override
	public void mouseDragged(MouseEvent e) {
		Point pt = e.getPoint();
		JComponent parent = (JComponent) e.getComponent();

		if (startPt != null
				&& Math.sqrt(Math.pow(pt.x - startPt.x, 2)
						+ Math.pow(pt.y - startPt.y, 2)) > gestureMotionThreshold) {
			startDragging(parent, pt);
			startPt = null;
			return;
		}
		if (!window.isVisible() || draggingComonent == null) {
			return;
		}

		Dimension d = draggingComonent.getPreferredSize();
		Point p = new Point(pt.x - d.width / 2, pt.y - d.height / 2);
		SwingUtilities.convertPointToScreen(p, parent);
		window.setLocation(p);

		for (int i = 0; i < parent.getComponentCount(); i++) {
			Component c = parent.getComponent(i);
			Rectangle r = c.getBounds();
			int ht2 = r.height / 2;
			Rectangle r1 = new Rectangle(r.x, r.y, r.width, ht2);
			Rectangle r2 = new Rectangle(r.x, r.y + ht2, r.width, ht2);
			if (r1.contains(pt)) {
				swapComponentLocation(parent, gap, gap, i - 1 > 0 ? i : 0);
				return;
			} else if (r2.contains(pt)) {
				swapComponentLocation(parent, gap, gap, i);
				return;
			}
		}
		parent.remove(gap);
		parent.revalidate();
	}