Here you can find the source of captureScreen(final Rectangle screenRect)
public static BufferedImage captureScreen(final Rectangle screenRect) throws AWTException
//package com.java2s; //License from project: Open Source License import java.awt.AWTException; import java.awt.Rectangle; import java.awt.Robot; import java.awt.image.BufferedImage; public class Main { private static Robot robot; public static BufferedImage captureScreen(final Rectangle screenRect) throws AWTException { if (robot == null) { throw new AWTException("the platform configuration does not allow low-level input control"); }// ww w .ja va2 s . c o m return robot.createScreenCapture(screenRect); } }