Friday, February 13, 2015
Java Program to Take Screenshots
There might be a situation where you guys want to take screen shots programmatically. So I am sharing a program that help you to take screen capture of your screen and save it in PNG (Portable network graphic) picture format.
Also Read: Java Program to Find IP Address
The below program uses Java.awt.Robot class to capture the screen pixels and uses Imageio to save it as PNG image format. Just copy and paste the program in Notepad, save it and run the program to take screen shot.
Note: The Screen shot image will be stored at the location where your program is stored.
If you liked the article please do share!!
Source: http://viralpatel.net/blogs/how-to-take-screen-shots-in-java-taking-screenshots-java/
Also Read: Java Program to Find IP Address
The below program uses Java.awt.Robot class to capture the screen pixels and uses Imageio to save it as PNG image format. Just copy and paste the program in Notepad, save it and run the program to take screen shot.
Note: The Screen shot image will be stored at the location where your program is stored.
Java Program to Take Screenshots
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.imageio.*;
class Snap
{
public static void main(String args[]) throws Exception
{
Robot awt_robot = new Robot();
BufferedImage Entire_Screen = awt_robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
ImageIO.write(Entire_Screen, "PNG", new File("Entire_Screen.png"));
}
}
If you liked the article please do share!!
Source: http://viralpatel.net/blogs/how-to-take-screen-shots-in-java-taking-screenshots-java/
Labels:
java,
program,
screenshots,
take,
to
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.