Java image FAQ: Can you show me how to create a screen capture in Java?
I don't have any Java screen capture code to share at the moment, but if you don't mind a JRuby screen capture example (which you can easily convert to Java), this JRuby screenshot (screen capture) source code example should help point you in the right direction:
include_class 'java.awt.Robot' include_class 'java.awt.Toolkit' include_class 'java.awt.Dimension' include_class 'java.awt.Rectangle' include_class 'java.awt.image.BufferedImage' include_class 'javax.imageio.ImageIO' def create_screen_shot robot = Robot.new toolkit = Toolkit.getDefaultToolkit dim = toolkit.getScreenSize rectangle = Rectangle.new(0, 0, dim.getWidth, dim.getHeight) screen_capture = robot.createScreenCapture(rectangle) end
As you can see, this example is written in JRuby, but I think you can translate it to Java very easily. (JRuby is basically an implementation of the Ruby programming language in Java, and lets you access Java classes, which I've done in this example screenshot (screen capture) code.
As you can see from this example, you create a screenshot in Java using the Robot class. Just create a Rectangle the size of the screen you want to capture, and then use to the Robot class createScreenCapture method to create the screen capture.