That seems like a bad idea, prone to unnecessary complications. Just make your class inherit from Component.
I want the LayerComponent to be selectable on the GUI, since juce::Component can’t be selected, so I chose to inherit from Label, based on BingAI’s suggestion. and even I make class inherit from Component, still can not setup the background colour in MainComponent().
I want the LayerComponent to be selectable on the GUI, since juce::Component can’t be selected, so I chose to inherit from Label, based on BingAI’s suggestion. and even I make class inherit from Component, still can not setup the background colour in MainComponent().
In your MainComponent::paint() function, you are specifically filling the whole background with black. If you want some other colour, that is where you do it.
You can add a background rectangle component into your container, and in the paint() function of that component you can use g.setColour() and g.fillRect() to fill the background.
Or simply add those lines into the paint() function of your current container.
If you are willing to change the background color of a Label, I would suggest using your custom LookAndFeel and override the function drawLabel().
For example, here is my custom lookandfeel and how my custom button uses the Label.
I hope you will find it helpful.
That’s a terrible idea. You seem to think that these generic AIs have real knowledge they can impart on you. That’s not the case. They make stuff up as the go along. It’s like somebody just skimmed over the documentation and then claims to be an expert.
I’ve personally given up on AI-assisted programming completely. It makes more mistakes than even the most beginner programmer. It’s pathetic how bad it is.
Even though Label has Component as base class and a Component is a container class, it is not advisable to use anything else than Component for a group of components (except maybe GroupComponent
). The reason is that Label already implements special behaviour, that interferes with the changes you made when inheriting from it.
As suggested before: inherit juce::Component, add your child components and override resized() to layout the child components and paint() to draw at a minimum the background using g.fillAll(juce::Colours::grey) or similar and anything else you want to draw.
I make LayerComponent inheriting from Component now, and in LayerComponent’s paint() progam g.fillRect() and g.fillAll(juce::Colours::red) as below shows;, it works.
I make LayerComponent inheriting from Component now, and in LayerComponent’s paint() progam g.fillRect() and g.fillAll(juce::Colours::red) as below shows;, it works.
I make LayerComponent inheriting from Component now, and in LayerComponent’s paint() progam g.fillRect() and g.fillAll(juce::Colours::red) as below shows;, it works.
First you fillAll with red, then you fill a rectangle that covers that whole area with gold. Remove the rectangle filled with gold, and you should see red, I would think. You’re drawing gold on top of the red.
Yes, I agree with you, I am new to juce, and juce using BingAI providing beginner help for me.
ok,I so happy it works, thank you, Thank you for all your kindness.
This is a good example of customizing the appearance of a control, near future I will also use it to design the appearance of controls in my projects as well, then it will be my guidance document,thank you very much for providing it to me.

