# (re)painting a particular component within a compound component?

**URL:** <https://forum.juce.com/t/re-painting-a-particular-component-within-a-compound-component/31394>\
**Category:** Getting Started\
**Created:** [January 22, 2019, 3:01am UTC](https://forum.juce.com/t/re-painting-a-particular-component-within-a-compound-component/31394 "2019-01-22T03:01:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![duggle](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@duggle](https://forum.juce.com/u/duggle)\
**Post date:** [January 22, 2019, 3:01am UTC](https://forum.juce.com/t/re-painting-a-particular-component-within-a-compound-component/31394/1 "2019-01-22T03:01:04Z")

</div>

I have an array of compound components (class derived from component that contains various components…) that each contain a slider.  
When another part of the app updates the position of the slider, it calls a method of the compound component that does nothing more that call mySlider.setValue();  
It turns out that the paint method of the whole compound component is called each time.  
Is it possible to have it only redraw the slider and not the whole component?

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [January 22, 2019, 2:39pm UTC](https://forum.juce.com/t/re-painting-a-particular-component-within-a-compound-component/31394/2 "2019-01-22T14:39:16Z")

</div>

There’s probably a way, but you’ll have to share a simple example to get some more help.

---

<div class="post-metadata">

**Author:** ![alassandro](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/alassandro/32/4297_2.png) [@alassandro](https://forum.juce.com/u/alassandro)\
**Post date:** [January 22, 2019, 5:50pm UTC](https://forum.juce.com/t/re-painting-a-particular-component-within-a-compound-component/31394/3 "2019-01-22T17:50:18Z")

</div>

If your sliders aren’t marked opaque (`juce::Component::setOpaque()`) then the parent component will also repaint itself just in the area of the child’s bounds.

It should be the case that the parent isn’t repainting its entire area if a child repaints, but you can double check by enabling `JUCE_ENABLE_REPAINT_DEBUGGING` in your project’s `AppConfig.h`. This will highlight sections of the screen as they’re repainted, and it should just show flashing colors around the sliders when they change.

---

<div class="post-metadata">

**Author:** ![duggle](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@duggle](https://forum.juce.com/u/duggle)\
**Post date:** [January 24, 2019, 11:28am UTC](https://forum.juce.com/t/re-painting-a-particular-component-within-a-compound-component/31394/4 "2019-01-24T11:28:47Z")

</div>

SetOpaque() seems to be what I’ve been wanting. The component does need to be opaque otherwise all kinds of artefacts are rendered (as you’d expect).  
I’ve enabled the `JUCE_ENABLE_REPAINT_DEBUGGING` but have not observed the flashing (I haven’t been drawing child over parent as yet just sibling over sibling but I will explore this more.
