I am trying to take many screenshot in Java using Robot class in order to record my screen. The problem is, when i take it at 15 fps-30 fps the cursor is flickering. How can I solve the problem ? I am working with Java 7 32 bits.
Asked
Active
Viewed 540 times
1
-
This similar question suggests that it's not possible: http://stackoverflow.com/questions/2962271/how-to-capture-screen-image-with-mouse-pointer-on-it-in-java, and http://stackoverflow.com/questions/21206986/how-to-capture-mouse-cursor-in-java – kuporific Sep 06 '14 at 23:55
-
It sounds like you're trying to make a video (15-30 fps) and `Robot` might not be the best solution here, try [Java Screen Recorder](https://code.google.com/p/java-screen-recorder/) or something similar instead. – kuporific Sep 06 '14 at 23:58
-
Hello, Java Screen Recorder use Robot class to take screenshot in order to record the screen... So it's the same problem... The link you gave to me is not the same question as mine, I wanted means my crusor disapear FROM my screen, not only on the screenshot. – user2663781 Sep 07 '14 at 07:55
-
I tried with Java 8 32 bits and I had better performence with my screenshot and there were no problem with the cursor. EDIT: I tried it on League of Legends and my cursor flickering again, so it's not a java version problem. – user2663781 Sep 07 '14 at 08:05
-
When taking a screenshot using `java.awt.robot`, the system will hide the mousecursor for the split second, until the screen is captured. So, if you take 15 screenshots a second, the system will hide the cursor 15 times, causing it to appear flickering for the user, depending on the systems performance. – dognose Oct 20 '14 at 15:11
-
I forwarded this to the JDK team. https://mail.openjdk.java.net/pipermail/client-libs-dev/2022-June/005463.html – Stefan Reich Jun 10 '22 at 14:42
1 Answers
0
Screen flickering may be caused because you are taking the screenshot too fast.
You should use some kind of timer to control the speed of your application, and make it run at around 60 frames per second.
Secondly, professional screen recorders normally have back buffers that stores previous screenshots, and only take a screenshot of the portion of the screen that actually changed.
Let's suppose you take a screenshot of your desktop. If you don't move your mouse or don't do anything, future screenshots may not be processed, because no changes were detected. If you move your mouse, only the portion of the screen that changed may be printed, and the rest should be the same as the previous screenshot.

Matias Cicero
- 25,439
- 13
- 82
- 154
-
1How would you detect which part of the screen changed in Java? There is no way to do it other than taking a new screenshot. – Stefan Reich Jun 10 '22 at 13:33