+ Reply to Thread
Results 1 to 2 of 2

Thread: Taking screen shots in Java

  1. #1
    Junior Member
    Join Date
    Jan 2012

    Taking screen shots in Java

    I'd like to take a screenshot of the screen in java , what is the snippet for that ? Thanks.
    Last edited by osource; 11-12-2012 at 03:07 AM.

  2. #2
    Junior Member
    Join Date
    Jan 2012
    This is the code i use to capture screen shots of the screen
    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));

+ Reply to Thread

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts