The code simply captures your working window as jpeg image and stores it in the same directory as where your java class after compiling by javac is being stored
Java code to capture your screen as image
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;
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("screenShot.jpg"));
}
}
Bharath15 0 Newbie Poster
ceers 0 Newbie Poster
Ghost_Ryder 0 Newbie Poster
ykpemre 0 Newbie Poster
BestJewSinceJC 700 Posting Maven
dhiralpandya 0 Newbie Poster
gyno -5 Light Poster
jacksonbird03 1 Newbie Poster
Obfuscator 0 Newbie Poster
Uday kiran_1 0 Newbie Poster
stultuske 1,116 Posting Maven Featured Poster
Ashan_1 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.