Help with Components Tabs

I am having a hard time getting tabs to display, the code compiles and runs, but there are no tabs at the top. I have added them with the add tab function and am using addandmakevisible, and I’ve checked to see if I’m running over it with another paint function, but I don’t think I am. Thanks for any help,

DemoTabbedComponent::DemoTabbedComponent() : TabbedComponent(TabbedButtonBar::TabsAtTop)
{
auto colour = Colours::blue;
addTab(“Buttons”, colour, new Spectro(), true);
addTab(“Sliders”, colour, new Tin_Oxide_Component(), true);
};
DemoTabbedComponent::~DemoTabbedComponent() {
}

class MainComponent : public Component
{
public:
//==============================================================================
MainComponent();
~MainComponent();
//==============================================================================
void paint(Graphics& g) override;
void resized() override;
private:
//==============================================================================
// Your private member variables go here…
DemoTabbedComponent tabs;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent)
};

MainComponent::MainComponent()
{
addAndMakeVisible(tabs);
setSize (1280, 720);
}
MainComponent::~MainComponent()
{
}
//==============================================================================
void MainComponent::resized()
{
// This is called when the MainComponent is resized.
// If you add any child components, this is where you should
// update their positions.
}
void MainComponent::paint(Graphics& g) {
}

Either you’re not setting the bounds of the tab control (or you’ve omitted the code where you do so). Probably you want to add the line

   tabs.setBounds(getLocalBounds()); 

to your MainComponent::resized() method (assuming you want the tab component to fill it completely…)

1 Like

Yooo. That worked. Thank you so much! I was trying to set the bounds in each components class declaration which was dumb.

1 Like