What Will I Learn?
- You will learn How to make a Multiple screen shot program using Java classes
Requirements
- System Requirements: Java JDK, Eclipse IDE or Netbeans IDE
- OS Support for Java:Windows, macOS, Linux
- Required Knowledge A fair knowlege of java Basics and fundamentals
Resources for Java and this tutorial:
- Oracle Website: https://www.oracle.com/index.html
- Java Docs:http://www.oracle.com/technetwork/java/javase/documentation/api-jsp-136079.html
- others : https://www.javaworld.com/article/2073446/screen-snapshots-with-java-s-robot.html
Description
Outline and Overview
Java provides API that allows Screen captured of your PC screen. Java robot class provides the method to enable this and it could be used to make screen shot programs or even video recorder program.
Classes needed
- File - Used to create a new file
- Rectangle - Used to get the Screen Dimension
- Robot - Does the actual screen capture and returns a bufferedImage object
- Bufferedimage - used to store the captured screen
- ImageIO - Used to write the buffered image to file
Before we start coding, lets create a new project
this is the code
public class ScreenCapture {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws AWTException, IOException {
// TODO code application logic here
// create a new Robot object
Robot robot = new Robot();
//get screen rectangle
Rectangle screenRectangle = new Rectangle(Toolkit.getDefaultToolkit() .getScreenSize());
// create a new file
File myFileOutput;
int count = 0;
long beforeTime = System.currentTimeMillis();
//capture current screen and save to Screencapture
while (count < 32) {
myFileOutput = new File(count + " screen.png");
BufferedImage Screencapture = robot.createScreenCapture(screenRectangle);
ImageIO.write(Screencapture, "png", myFileOutput);
count++;
}
double time = System.currentTimeMillis() - beforeTime;
System.out.println("Seconds it took for " + count + " screen captures: " + time / 1000);
System.out.println(count + " Images Captured!");
}
}
This is the build output
This is the file output
The Part #1 of this series
Mehhnn.. Boss.. Too bad... Utopian no deh upvote posts weh you use bots upvote.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
thanks for the info @ubongj, i'll take note of that
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Sneaky Ninja Attack! You have just been defended with a 6.20% upvote!
I was summoned by @enyason. I have done their bidding and now I will vanish...
woosh
A portion of the proceeds from your bid was used in support of youarehope and tarc.
Abuse Policy
Rules
How to use Sneaky Ninja
How it works
Victim of grumpycat?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit