Mouse button down = select coordinates
Mouse button released = select new coordinates and calculate difference.
Then you can move your shape, but it will move suddenly, rather than being dragged slowly.
There are two interfaces for mice: MouseListener and MouseMotionListener.
You should find suitable methods in one or other of those interfaces.