import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.File;
...
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));
}
...
Code language: Java (java)
Java URL Encoder/Decoder Example - In this tutorial we will see how to URL encode/decode…
Show Multiple Examples in OpenAPI - OpenAPI (aka Swagger) Specifications has become a defecto standard…
Local WordPress using Docker - Running a local WordPress development environment is crucial for testing…
1. JWT Token Overview JSON Web Token (JWT) is an open standard defines a compact…
GraphQL Subscription provides a great way of building real-time API. In this tutorial we will…
1. Overview Spring Boot Webflux DynamoDB Integration tests - In this tutorial we will see…
View Comments
See this site http://www.screencast-o-matic.com/
It uses the Robot class to create the screen cast
Thanks Suresh for the link.
Great!!!!!
i have managed to take screenshot but i am failing to display it . It gives nullpointerexception for following code
JPanel p=new JPanel();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Rectangle screenRectangle = new Rectangle(screenSize);
Robot robot = new Robot();
BufferedImage image = robot.createScreenCapture(screenRectangle);
ImageIcon img=(ImageIcon)image;
Image im=img.getImage();
Graphics g;
g.drawImage(im,0,0,p);
plz help me................
Change it to :
g.drawImage(im, 0, 0, p, this);
Eclipse showed major errors it ddint work at all..
Class - thankx
How to save file after taking screenshot in a specific path like....
D:\New Folder
Thank you
I would like to know how can I take screenshots randomly using the same coding.