怎么用java获取屏幕上特定位置的图片

来源:百度知道 编辑:UC知道 时间:2024/06/04 10:48:09
怎么用java获取屏幕上特定位置的图片啊?
比如说我想要获取最上面窗口内特定位置的图片,用JAVA怎么实现呢?

class Test {

public static void main(String[] args) {
Robot robot = null;
try {
robot = new Robot();
} catch (AWTException ex) {
Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
}
BufferedImage image = robot.createScreenCapture(new Rectangle(0, 0, 200, 200));
JOptionPane.showConfirmDialog(null, args, null, JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, new ImageIcon(image));
}
}

参考下这个