これを試して
public class Main {
private Robot robot = new Robot();
public Main() throws AWTException, IOException {
int x = 800;
int y = 800;
int width = 200;
int height = 200;
imageCapture(x, y, width, height);
}
private void imageCapture(int x, int y, int width, int height) throws IOException {
Rectangle area = new Rectangle(x, y, width, height);
BufferedImage bufferedImage = robot.createScreenCapture(area);
//remove next line if u do not want file.png saved
ImageIO.write(bufferedImage, "png", new File("file.png"));
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws AWTException, IOException {
new Main();
}/**
* @return the robot
*/
public Robot getRobot() {
return robot;
}
/**
* @param robot the robot to set
*/
public void setRobot(Robot robot) {
this.robot = robot;
}
}
プロジェクトにもfile.pngを作成します