Try
Rectangle rect = new Rectangle(0, 0, 700, 500);
BufferedImage screencapture = new Robot()
.createScreenCapture(rect);
// Save as JPEG
File file = new File("FileName.Jpg");
ImageIO.write(screencapture, "jpg", file);
Interesting question is what will happen if this code is executed in an environment where display devices are not available? You will get an AWT exception indicating "headless environment".
No comments:
Post a Comment