# Refreshing graphics with paint()?

**URL:** <https://forum.juce.com/t/refreshing-graphics-with-paint/24983>\
**Category:** General JUCE discussion\
**Created:** [November 4, 2017, 3:27pm UTC](https://forum.juce.com/t/refreshing-graphics-with-paint/24983 "2017-11-04T15:27:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![theaudioprogrammer](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/theaudioprogrammer/32/18383_2.png) [@theaudioprogrammer](https://forum.juce.com/u/theaudioprogrammer)\
**Post date:** [November 4, 2017, 3:27pm UTC](https://forum.juce.com/t/refreshing-graphics-with-paint/24983/1 "2017-11-04T15:27:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cpr2323](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/cpr2323/32/18682_2.png) [@cpr2323](https://forum.juce.com/u/cpr2323)\
**Post date:** [November 4, 2017, 3:36pm UTC](https://forum.juce.com/t/refreshing-graphics-with-paint/24983/2 "2017-11-04T15:36:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 4, 2017, 8:04pm UTC](https://forum.juce.com/t/refreshing-graphics-with-paint/24983/3 "2017-11-04T20:04:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![theaudioprogrammer](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/theaudioprogrammer/32/18383_2.png) [@theaudioprogrammer](https://forum.juce.com/u/theaudioprogrammer)\
**Post date:** [November 5, 2017, 11:08am UTC](https://forum.juce.com/t/refreshing-graphics-with-paint/24983/4 "2017-11-05T11:08:19Z")

</div>

The AnimatedAppComponent class did the trick. Thanks!

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 5, 2017, 11:59am UTC](https://forum.juce.com/t/refreshing-graphics-with-paint/24983/5 "2017-11-05T11:59:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![theaudioprogrammer](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/theaudioprogrammer/32/18383_2.png) [@theaudioprogrammer](https://forum.juce.com/u/theaudioprogrammer)\
**Post date:** [November 5, 2017, 9:24pm UTC](https://forum.juce.com/t/refreshing-graphics-with-paint/24983/6 "2017-11-05T21:24:34Z")

</div>

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