Screenshots are an important way to store important information for future reference. This is easy until the time we have a small number of screenshots. But when you have a large number of screenshots, you would probably like to manage them and find a way to search out any of your screenshots by a simple search. Virtual Screenshot Manager makes this possible.
Using the Code
We will now discuss the important part of coding . We start with the main functionality, i.e., capturing the full or cropped screen.
Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
Robot robot = new Robot();
BufferedImage img = robot.createScreenCapture(new Rectangle(size));
Here we take a screenshot. The portion for which we take a screenshot will be described by the var
Now when we have made a screenshot, we save it to a predefined location.
File save_path = new File(imgPath+"1.jpg");
ImageIO.write(img, "JPG", save_path);
Now this image will be saved. When you save the next image, you update the counter so that the next one gets saved as 2.jpg.
Next, we open a popup asking to enter information about this screenshot which we may use to search the image later.
We write all screenshot information as below:
FileOutputStream fout = new FileOutputStream("ImageInfo.dat");
ObjectOutputStream oos = new ObjectOutputStream(fout);
imd is an object which contains information about the cropped image. We write this inside a serialized class which we can later read to either display or search the screenshot.
Now to show images, we use:
list1 = new JLabel(new ImageIcon(Img + ".jpg"));
This will display a new screenshot. Likewise, we may show the remaining screenshots. For my software, I am numbering the screenshots.
For searching, we give a search term and use it to check the dat files.
Points of Interest
I learned how easy it is to learn NetBeans and it can do wonderful things. This is all from my side for now. Please let me have your valuable feedback.
I am a Java software developer. I like to make new software which can be helpful to people. You may get in touch with me at https://cooltrickshome.blogspot.in