setContentOwned takes entire component

Learning about JUCE as I play with it. Something unexpected happened, it’s got to be how JUCE is designed, but perhaps someone can help me up the learning curve.

Using the HelloWorldWindow demo app as my foundation, I was surprised what happens with two custom components. Using JUCE two components were created A and B.
Either can be placed in the HelloWorldWindow constructor with setContentOwned and each works fine. When I add both, only the last one is displayed at runtime. I’m guessing the earlier one is “underneath”.

I’d like to build my UI with my own custom components, each likely compound components themselves. Using the Tab object is one approach.

I’m wondering how these components would be sized when run, including a circumstance where some of the subcomponents may come and go during runtime.

So we might have A and B sharing the screenspace, but then C might take the space of B completely, or share it.

Can someone point me in the right direction?

Oh, my main objective - at this stage - is trying to get something done easily. My thought had been to build things in pieces and get them working, and then assembling them would be easier. But if I hear “Just make one window component for now” there will be no argument :wink:

There’s only one content component for a window… If you call setContentOwned twice, the second time will just replace and delete the previous component.

A window can only have one content component, but a component can have many children components. Make a single component for the window, then add compnents A and B to the content component as children (addChildComponent, or the shortcut addAndMakeVisible).

Ah, that makes sense now.

Thank you.