@Override
    public void mouseReleased(MouseEvent e) {
        // Is there a final point? At this stage, this means a rectangle is constructed.
        if (finalX > 0 && finalY > 0) {
            String dialogMsg = "Would you like to crop the image to the specified size?";
            int doCrop = JOptionPane.showConfirmDialog(null, dialogMsg, "SwiftSnap", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE);
            // If the user decides to crop the image using the rectangle...
            if (doCrop == JOptionPane.YES_OPTION) {
                // Crop and save the image.
                Screenshot.crop(new Rectangle(initialX, initialY, finalX - initialX, finalY - initialY));
                Screenshot.save();
                window.destroyWindow();
            }
        }
        
        // Reset some values and clear the canvas.
        initialX = 0;
        initialY = 0;
        finalX = 0;
        finalY = 0;
        clearCanvas = true;
        repaint();
    }