public static ScreenshotImage takeScreenShot() {
        if (robot == null) {
            try {
                robot = new Robot();
            } catch (AWTException ex) {
                System.err.println(ex.getMessage());
                return null;
            }
        }
        
        // Get the dimensions of the screen.
        Dimension window = Toolkit.getDefaultToolkit().getScreenSize();
        Rectangle screen = new Rectangle(window);
        
        // Take a screenshot using the screen dimensions.
        BufferedImage screenshotImage = robot.createScreenCapture(screen);
        ScreenshotImage screenshot = new ScreenshotImage(screenshotImage, screenshotImage.getWidth(), screenshotImage.getHeight());
        // Cache the screenshot (to use cropping and saving methods).
        lastScreenshot = screenshot;
        return screenshot;
    }