public void mouseReleased(MouseEvent me) {
if (dragging) {
Point clickPoint = SwingUtilities.convertPoint(glassPane,
me.getPoint(), m_elemPanel);
DisplayElement dragTargetDE = (DisplayElement) dragTarget;
int xoffset = clickPoint.x - dragPosition.x;
int yoffset = clickPoint.y - dragPosition.y;
Point newLocation = new Point(xoffset + dragTarget.getX(),
yoffset + dragTarget.getY());
// This code assumes that dragTargetDE.getLayoutAllocation()
// will never be null since
// objects are put on the screen (and are this draggable) only
// if they were assigned an allocation
LayoutAllocation newLa = LayoutAllocator.forceMoveAllocation(
dragTargetDE.getLayoutAllocation(), newLocation);
dragTargetDE.setLayoutAllocation(newLa);
dragTargetDE.setLocation(newLa.point);
}
dragging = false;
captureMouse(me);
}