previous
contents
next

Starting a Drag

public void mousePressed(MouseEvent event) {
   // Get mouse position
   int mouseX = event.getX();
   int mouseY = event.getY();
   // Check if the mouse is inside the image
   if (mouseX >= imageX &&
        mouseX <= imageX + imageWidth &&
        mouseY >= imageY &&
        mouseY <= imageY + imageHeight)
              draggingImage = true;
}