@Override
    public void paintComponent(Graphics g) {
        // Set the brush color.
        g.setColor(new Color(255, 0, 0, 128));
        // If the canvas is requested to be cleared, clear the screen.
        if (clearCanvas) {
            g.clearRect(0, 0, totalScreenWidth, totalScreenHeight);
            clearCanvas = false;
        }
        
        g.drawImage(Screenshot.getLastScreenshot(), 0, 0, this);
        g.setFont(new Font("Arial", Font.PLAIN, 20));
        g.drawString("Set a point and drag your mouse to create a rectangle.", 50, 50);

        // If there is a final (which implies an initial as well) point.
        if (finalX > 0 && finalY > 0) {
            // Get the point to start drawing and the size of the rectangle.
            g.drawRect(initialX, initialY, finalX - initialX, finalY - initialY);
        } else if (initialX > 0 && initialY > 0) { // Initial points set only?
            // Draw the initial point.
            g.fillRect(initialX, initialY, 5, 5);
        }
    }