Switching between independent components in JUCE

I want to create a button that can switch between two independent components. I can use
this->setVisible(false); to remove my current GUI component but I am unable to put a different component in its place. Even though I create a new object called mainContentComponent and try the following mainContentComponent->setVisible(true); Does anyone have any suggestions on switching independent components that are located in different cpp files? All help is appreciated!

Should actually work like that. Did you call addAndMakeVisible on the new one as well?
And did you set the bounds in the resize method for the new one?
If it was created after setSize, it might not have received a valid size…
Good luck

1 Like