+-+-+ +-+ +-+-+-+-+
|G|O| |4| |H|I|V|E|
+-+-+ +-+ +-+-+-+-+

 --- A GOPHER-LIKE INTERFACE FOR HIVE BLOCKCHAIN ---

Java Tutorial : How to make PC ScreenShot program with Java #2 - Multiple Shot

BY: @enyason | CREATED: May 21, 2018, 8 a.m. | VOTES: 10 | PAYOUT: $3.98 | [ VOTE ]

 https://steemitimages.com/0x0/https://steemitimages.com/DQmUk4XVXj3xBo3ZCab8MmffJF8wV82yZrKXSbokgK5Ny8W/java-mini-logo.jpg

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

https://steemitimages.com/DQmPVPi7Dtgn1KFFcNVCGGcmktJ7PVo6cnYfLpyu1pGTNN6/screenCaptureCreateNewProject.png

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

https://steemitimages.com/DQmYRJxSYb3aCRF12gErcNx3vhebTLiFvpUUZYTM8fs59Lw/buildOutputMultipleScreenShoot.png

This is the file output

https://steemitimages.com/DQmfSZ4XtK7ThUVgGc8rW9qcu6qJxG1oqxzd3ySpNkVfhyu/FileOutputMultipleScreenShot.png

The Part #1 of this series

https://steemit.com/utopian-io/@enyason/java-tutorial-how-to-make-pc-screenshot-program-with-java-1-single-shot

TAGS: [ #utopian-io ] [ #development ] [ #java ] [ #programming ] [ #technology ]

Replies

@sneaky-ninja | May 21, 2018, 10:32 p.m. | Votes: 1 | [ VOTE ]

[IMAGE: https://steemitimages.com/DQmde7XXhkKjmxyqBbBPTwkaiuXXrtQe6qXoWmCDZL1nD2B/sneaky-ninja-sword-xs.jpg]
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?

@ubongj | May 22, 2018, 12:01 p.m. | Votes: 2 | [ VOTE ]

Mehhnn.. Boss.. Too bad... Utopian no deh upvote posts weh you use bots upvote.

@enyason | May 22, 2018, 8:12 p.m. | Votes: 0 | [ VOTE ]

thanks for the info @ubongj, i'll take note of that

[ BACK TO TRENDING ] [ BACK TO MENU ]
CMD>