import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
/**
* 抓取全屏图片
* @author YangZhiFeng
* @version 1.0
* @created 2012-5-24 下午04:16:00
*/
public class Fullscreen
{
/**
*
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception
{
Fullscreen ta=new Fullscreen();
ta.captureScreen("D:\\a.jpg");
}
/**
* 抓取全屏图片
* @param fileName:图片保存地址
* @throws Exception
*/
public void captureScreen(String fileName) throws Exception {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Rectangle screenRectangle = new Rectangle(screenSize);
Robot robot = new Robot();
BufferedImage image = robot.createScreenCapture(screenRectangle);
ImageIO.write(image, "png", new File(fileName));
}
}