Red Security
Tutorial Taking Screenshot in Java - Printable Version

+- Red Security (https://redsecurity.info/cc)
+-- Forum: Programming (https://redsecurity.info/cc/forumdisplay.php?fid=5)
+--- Forum: Java (https://redsecurity.info/cc/forumdisplay.php?fid=7)
+--- Thread: Tutorial Taking Screenshot in Java (/showthread.php?tid=1416)



Taking Screenshot in Java - Mr.Kurd - 03-09-2020

In The Name OF Allah
Al-Salam Alekum

[Image: Java_logo_icon.png]

Hello guys, Today am gonna give you source code of a simple project which is about taking screenshot using Java Smile

Code:
            // Starting a Robot which is going to take the screenshot for us.
            Robot r = new Robot();
 
            // It saves screenshot to desired path
            String path = "/home/Desktop/Screenshot.jpg";
 
            // Used to get ScreenSize and capture image
            Rectangle capture = 
            new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
            BufferedImage Image = r.createScreenCapture(capture);
           
            // Saving the image to given path from the Buffered Data above.
            ImageIO.write(Image, "jpg", new File(path));


I hope this help you in the future....
Thank you for reading.. Java is Fun Smile .


 Wa Salam Alekum