Change Component Colour


Have started programing using JUCE just 2 days back. WIll really appreciate some help on some fundamentals.
I have a DocumentWindow which holds one component having some widgets like buttons, labels on it.

I would like to have different background colour for Window and and a different background colour for the component. To check how a window differs from the component. Is it possible ? Please help.


For the DocumentWindow you can change the background colour by specifying a value in the constructor:

    DocumentWindow (const String& name,
                    const Colour& backgroundColour,
                    int requiredButtons,
                    bool addToDesktop = true);

For components, the function is setColour() and the colourId comes from an enumeration that each class provides. Here’s an example for a Label:

Label* label = new Label;
label->setColour (Label::textColourId, Colours::orange);

This works the same on all platforms, not just Windows.

Hi Vinn,

Thanks for your reply. It worked out fine by using the graphics object in the paint() function.