I'm missing something obvious -- help me see it

I have a couple of Labels and Text Editors and a pair of radio buttons I want to appear and disappear as a group. So I create them all in a Group Box in the Jucer. The code the Jucer generates creates the elements and adds them to the top level component. So, in the constructor I addAndSetVisible() all the elements to the GroupComponent.

The elements are properly added to the GroupComponent’s child list. But the x & y positions are still relative to the top level component they were originally added to. So, when the parent’s internalRepaint() does the vertical clipping check, it finds that (the original) y + h is > the height of the parent. So, a new h is calculated as the parent height - (the original) y, invariably ending up with a negative number for all the elements. So nothing gets repainted.

What am I doing wrong? How can I accomplish this common action in JUCE?

TIA for any help.


You really need to put them in their own sub-component, if you start shuffling them around yourself, then none of the jucer-generated code can be expected to work properly. It’s easy to embed jucer components inside other ones.

yeah i had to write my own grouping code for the GroupComponent, it really is just a black frame with a name and has no dependency on components inside or outside it.

Yeah, that’s what I get for coding into the wee hours after a day of hard labor…too little blood in the brain, I guess.

I guess that’s what you get for writing such a comprehensive library, Jules. Some part of my brain was expecting it to read my mind and know I’d created the sub-component in the Jucer so it should re-calc the position relative to the new parent when I changed the parent.


I fiddled with using relativePositionToOtherComponent() and setting the position manually with no success. So I’ll bite the bullet & create the embedded components in the Jucer. PITA since I have 3 levels of embedding, but it’ll certainly fix the lesson learned into my grey matter.