/Users/lyon/j4p/src/bookExamples/ch26Graphics/ScreenCapture.java

1    package bookExamples.ch26Graphics; 
2     
3    /** 
4     * Copyright DocJava, inc. User: lyon 
5     * <p/> 
6     * Date: Nov 7, 2004 
7     * <p/> 
8     * Time: 7:08:44 AM 
9     */ 
10    
11   import j2d.ImageUtils; 
12    
13   import javax.imageio.ImageIO; 
14   import java.awt.*; 
15   import java.awt.image.BufferedImage; 
16   import java.io.File; 
17   import java.io.IOException; 
18    
19   class ScreenCapture { 
20       public static void main(String args[]) throws 
21                                              AWTException, IOException { 
22           // capture the whole screen 
23           BufferedImage screencapture = ImageUtils.captureWholeScreen(); 
24    
25           // Save as JPEG 
26           File file = new File("screencapture.jpg"); 
27           ImageIO.write(screencapture, "jpg", file); 
28    
29       } 
30    
31   } 
32    
33