Here you can find the source of screenshot(Rectangle dims, Robot r)
public static BufferedImage screenshot(Rectangle dims, Robot r)
//package com.java2s; //License from project: Open Source License import java.awt.*; import java.awt.image.BufferedImage; public class Main { public static BufferedImage screenshot(Rectangle dims, Robot r) { BufferedImage screenshot = r.createScreenCapture(dims); return screenshot; }//from w w w . ja v a 2s . c om }