Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8516203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:21:33+00:00 2026-06-11T05:21:33+00:00

I wrote a GUI-based Java program that takes 25 screenshots per second and saves

  • 0

I wrote a GUI-based Java program that takes 25 screenshots per second and saves them at a user-defined location.
It works pretty well except that it has two problems:

  • The mouse cursor is missing from the images and I know it will be because BufferedImages do not contain cursor information in them. They have to be added programatically.
  • The thread that takes screenshots is a daemon thread. So if I close the application, the thread is killed and the PNG image that was being written gets corrupted. I want to avoid that.
  • Here are the images of my application:
    The award-winning, intuitive GUI:
    enter image description here

    The high-definition images captured look like this:
    enter image description here
    As you can see from the image the cursor information is being displayed in the console using MouseInfo‘s static methods.

    Please let me know how to solve the above mentioned two problems.
    After solving the problem, the images now look like this:
    with cursor

    • 1 1 Answer
    • 0 Views
    • 0 Followers
    • 0
    Share
    • Facebook
    • Report

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Forgot Password?

    Need An Account, Sign Up Here

    1 Answer

    • Voted
    • Oldest
    • Recent
    • Random
    1. Editorial Team
      Editorial Team
      2026-06-11T05:21:35+00:00Added an answer on June 11, 2026 at 5:21 am

      The mouse cursor is missing from the images and I know it will be
      because BufferedImages do not contain cursor information in them. They
      have to be added programatically.

      That is correct, you have to add the cursor afterwards. The reason for this is that a screenshot taken with the Robot class never contains the cursor. Not really because “the BufferedImage doesn’t contain mouse info”. A BufferedImage is a class that contains a raster of pixels.

      The thread that takes screenshots is a daemon thread. So if I close
      the application, the thread is killed and the PNG image that was being
      written gets corrupted. I want to avoid that.

      Simply, in the screenshot thread, use a flag that indicates wether it should continue or not. Keep taking screenshots as long as that boolean is set to true. Make sure to make it non-deamon. So, when you close the application, set the flag to false.
      Probably the most easy way to do this is to add a WindowListener:

      yourFrame.addWindowListener(new WindowAdapter()
      {
          public void windowClosed(WindowEvent e)
          {
              screenshotThread.stopTakingScreenshots(); // This methods set the flag
          }
      }
      

      Also notice that you are not taking the time it takes to make and save a screenshot in count. You use a fixed sleep of 40 milliseconds, but let’s say that it takes 4 milliseconds to take and save the screenshot, then you should sleep for only 36 milliseconds. To time how long it takes to make the screenshot, use System.currentTimeMillis(); before and after your takeShot() method and make the difference.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
        • Report

    Sidebar

    Related Questions

    i have a command line based program that i want to write a gui
    I have written a small GUI based vb.net program that speaks to embedded devices
    I am using Eclipse. I wrote a little Java Gui Tool that depends on
    I wrote this short program which has a tiny GUI. Its supposed to allow
    I need to write a simple terminal-based program that should, Read some text from
    I'm writing a user's GUI and I want to create a method that will
    I wrote a quick program in python to add a gtk GUI to a
    this is a general question about GUIs. I never wrote a program with GUI,
    I'm trying wxpython for the first time. I've wrote a GUI for a python
    I wrote a Python GUI script with Tkinter, and now I want to convert

    Explore

    • Home
    • Add group
    • Groups page
    • Communities
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Polls
    • Tags
    • Badges
    • Users
    • Help
    • SEARCH

    Footer

    © 2021 The Archive Base. All Rights Reserved
    With Love by The Archive Base

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.