# Can't change text colour on linearbar sllider

**URL:** <https://forum.juce.com/t/cant-change-text-colour-on-linearbar-sllider/61498>\
**Category:** General JUCE discussion\
**Created:** [May 21, 2024, 10:23pm UTC](https://forum.juce.com/t/cant-change-text-colour-on-linearbar-sllider/61498 "2024-05-21T22:23:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ulfl](https://avatars.discourse-cdn.com/v4/letter/u/b5a626/32.png) [@ulfl](https://forum.juce.com/u/ulfl)\
**Post date:** [May 21, 2024, 10:23pm UTC](https://forum.juce.com/t/cant-change-text-colour-on-linearbar-sllider/61498/1 "2024-05-21T22:23:41Z")

</div>

Hi!

I want to change the text colour on a linear bar slider. I have overrided the drawLinearSlider method and tried to set these colours in my LookAndFeel constructor:

```auto
        setColour (Label::textColourId, Colours::black);
        setColour (Label::textWhenEditingColourId, Colours::white);
        setColour (Label::backgroundWhenEditingColourId, Colours::black);
        setColour (Label::outlineWhenEditingColourId, Colours::black);
        setColour (Slider::thumbColourId, Colours::white);
        setColour (Slider::textBoxTextColourId, Colours::black);
        setColour (Slider::textBoxBackgroundColourId, Colours::white);
        setColour (Slider::trackColourId, Colours::grey);

```

But nothing works. The text is still white:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/juce/original/3X/b/0/b03c849a2d524937f99c3b279fd5161b9741b342.png)

Any ideas?

Thanks,  
ulfl

---

<div class="post-metadata">

**Author:** ![zsliu98](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/zsliu98/32/22502_2.png) [@zsliu98](https://forum.juce.com/u/zsliu98)\
**Post date:** [May 22, 2024, 1:44am UTC](https://forum.juce.com/t/cant-change-text-colour-on-linearbar-sllider/61498/2 "2024-05-22T01:44:19Z")

</div>

You may customize those colours by overriding `drawLabel()` method.  
Perhaps there is also a way to set it with those ColourIds. However, I am not familiar with them.

---

<div class="post-metadata">

**Author:** ![Valerio64](https://avatars.discourse-cdn.com/v4/letter/v/e47c2d/32.png) [@Valerio64](https://forum.juce.com/u/Valerio64)\
**Post date:** [May 22, 2024, 1:18pm UTC](https://forum.juce.com/t/cant-change-text-colour-on-linearbar-sllider/61498/3 "2024-05-22T13:18:44Z")

</div>

Just recently I also noticed similar anomalies in the text box of the linear sliders.  
windows10, juce 8 branch.  
new LookAndFeel settings work on the slider part, no effect on the text box.

the LookAndFeel does not update the new settings until you refresh it:

```auto
auto& laf = myGuiComponent.getLookAndFeel();

    laf.setColour(Slider::ColourIds::backgroundColourId, Colours::red);
    laf.setColour(Slider::trackColourId, Colours::green);               
    laf.setColour(Slider::thumbColourId, Colours::purple);             

    laf.setColour(Slider::ColourIds::textBoxOutlineColourId, Colours::white);
    laf.setColour(Slider::textBoxBackgroundColourId, Colours::purple);
    laf.setColour(Slider::textBoxTextColourId, Colours::black);
    laf.setColour(Slider::textBoxHighlightColourId, Colours::red);

// refresh the LookAndFeel
myGuiComponent.setLookAndFeel(&laf);

```

same with:

```auto
auto& laf = juce::LookAndFeel::getDefaultLookAndFeel();

// ... your colors here

juce::LookAndFeel::setDefaultLookAndFeel(&laf);

```

---

<div class="post-metadata">

**Author:** ![ulfl](https://avatars.discourse-cdn.com/v4/letter/u/b5a626/32.png) [@ulfl](https://forum.juce.com/u/ulfl)\
**Post date:** [May 22, 2024, 9:15pm UTC](https://forum.juce.com/t/cant-change-text-colour-on-linearbar-sllider/61498/4 "2024-05-22T21:15:35Z")

</div>

Thanks for the help! I added this to my LookAndFeel class:

```auto
LookAndFeel() {
        using namespace juce;
        
        auto& lnf = getDefaultLookAndFeel();
        lnf.setColour (Label::textColourId, Colours::black);
        lnf.setColour (Label::textWhenEditingColourId, Colours::white);
        lnf.setColour (Label::backgroundWhenEditingColourId, Colours::black);
        lnf.setColour (Label::outlineWhenEditingColourId, Colours::black);
        lnf.setColour (Slider::thumbColourId, Colours::white);
        lnf.setColour (Slider::textBoxTextColourId, Colours::black);
        lnf.setColour (Slider::textBoxBackgroundColourId, Colours::white);
        lnf.setColour (Slider::trackColourId, Colours::grey);
    }

```

That gives me the correct colors:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/juce/original/3X/0/9/09253d300fb2a69b1d60e7a63b68989b65a9524f.png)
