JavaClaDZ Admin
Posts : 18 Join date : 2008-02-23 Age : 33
| Subject: [TuT- Source Code] Screen Capture Program Sun Feb 24, 2008 1:16 am | |
| This Program captures your working window as jpeg image and stores it in the same directory as where your java class after compiling by javac. Note once you hit void main args it works after 5 sec check that programs folder Bellow is source code for a Screen Capture Progran in Java. - Code:
-
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;
/** * Takes a picture of the screen of your computer */
public class screen2image { public static void main(String[] args) throws Exception {
Robot robot = new Robot(); BufferedImage screenShot = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())); ImageIO.write(screenShot, "JPG", new File("YourscreenShot!.jpg"));
}
} | |
|