Refreshing graphics with paint()?

Hi, I’m working on a swarm intelligence algorithm in Juce, and am refreshing all my graphics positions in paint() but notice it’s lagging and not refreshing properly. I’m wondering if I’m correct in thinking of refreshing my graphics in the same way I’d think of void draw() in openFrameworks, or do I have this wrong?

Thanks for any help.

You probably want to do all of your calculations in a separate thread, and just do the drawing in paint().

If you’re after an openframeworks-style continuous repaint behaviour then maybe the AnimatedAppComponent class would do what you expect?


The AnimatedAppComponent class did the trick. Thanks!

Good, but you should learn about how paint/repaint works, because that’s the mechanism that pretty much every GUI system on every OS actually uses underneath.

1 Like

Thank you for the advice, I’ll have a look into it!