Question: How do I update the screen?
In Java+Swing, I am re- JFrame.getContentPane().repaint() ing 60 times per second. However, the screen does not show all of my repaints: it slows down repainting when my mouse is not over the window.
How do I fix this?
There are no error messages when any of these are run.
Here is a link to the repl: @JasonRoman/FreakingMath
This repl uses frame.setVisible(true), because it’s the only one that I’ve found that works, even if it annoyingly prevents you from focusing any other windows.
I have tried frame.revalidate, and it doesn’t work.
I forked your Repl and tried to replicate the issue. Unfortunately I wasn’t able to get the slowdown you experienced. I’ve posted a video here so you can check and let me know if this is different to what you experience:
The slowdown only seems to happen when the mouse is not on top of the window, and it happens less in Replit than it does running it locally.
Also, currently the repl uses frame.setVisible(true). While this does fix the problem and prevent the slowdown, it also keeps the window focused, preventing any other windows from getting focused. (For instance, try right-clicking, then selecting “Fluxbox menu” and then “Fluxbox Command”. You won’t be able to type anything because the java window is constantly focusing itself.)