I am calling repaint a bunch of times from a listeners, but the way I designed my paint function is only one repaint is required. I generate a bunch of repaints, since it hooked into my mouse motion listener.
Is there a way to cancel all pending repaints for a certain component? I can't just start ignoring repaints, since some are valid like when you resize the frame or restore it from minimize.
Why do I care? Because my paint code is very heavy and I can't do full repaints at a very high FPS.
Swing will combine repaints for you: see "Painting in AWT and Swing" on Sun's website. If you schedule a number of repaints in rapid succession, they'll get combined into a single call to paintImmediately().
Frequent repaint requests are automatically collapsed into one. The best way to optimize this is not to repaint the whole thing, but call repaint with coordinates of specific area. This means you repaint only the area which actually changed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With