# Tabs not showing in TabbedComponent's subclass

**URL:** <https://forum.juce.com/t/tabs-not-showing-in-tabbedcomponents-subclass/17077>\
**Category:** General JUCE discussion\
**Created:** [April 2, 2016, 8:58am UTC](https://forum.juce.com/t/tabs-not-showing-in-tabbedcomponents-subclass/17077 "2016-04-02T08:58:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![appjuce](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@appjuce](https://forum.juce.com/u/appjuce)\
**Post date:** [April 2, 2016, 8:58am UTC](https://forum.juce.com/t/tabs-not-showing-in-tabbedcomponents-subclass/17077/1 "2016-04-02T08:58:36Z")

</div>

My subclass of TabbedComponent doesn't display any tabs

Possibly, I am missing something obvious, but I run

out of ideas about how to get my subclass of TabbedComponent to display any tabs. &nbsp;

Please advise..

Here are the relevant fragments of my code:

- in **myTabbedComponent.h** file:

> class myTabbedComponent &nbsp;: public TabbedComponent  
> {  
> public:  
> &nbsp; &nbsp; //==============================================================================  
> &nbsp; &nbsp; myTabbedComponent ();  
> &nbsp; &nbsp; ~myTabbedComponent();
> 
> ...

- in &nbsp; **myTabbedComponent.cpp** &nbsp;file:

> myTabbedComponent::myTabbedComponent ()  
> &nbsp; &nbsp; : TabbedComponent (TabbedButtonBar::TabsAtTop)  
> {  
> &nbsp; &nbsp; //[Constructor\_pre] You can add your own custom stuff here..  
> &nbsp; &nbsp; addTab ("t1", Colours::lightgreen, 0, &nbsp; false);  
> &nbsp; &nbsp; addTab ("t2", Colours::lightgreen, 0, &nbsp; false);  
> &nbsp; &nbsp; addTab ("t3", Colours::lightgreen, 0, &nbsp; false);  
> &nbsp; &nbsp; //[/Constructor\_pre]  
>   
>   
> &nbsp; &nbsp; //[Constructor] You can add your own custom stuff here..  
> &nbsp; &nbsp; //[/Constructor]  
> }

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [April 2, 2016, 9:24am UTC](https://forum.juce.com/t/tabs-not-showing-in-tabbedcomponents-subclass/17077/2 "2016-04-02T09:24:29Z")

</div>

> addTab ("t1", Colours::lightgreen, 0, &nbsp; false);

...maybe try to give it a component instead of a null pointer (and please use nullptr instead of 0, if you need it).

e.g.

addTab ("t1", Colours::lightgreen, new Component(), &nbsp; true);

Good luck

---

<div class="post-metadata">

**Author:** ![appjuce](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@appjuce](https://forum.juce.com/u/appjuce)\
**Post date:** [April 3, 2016, 6:29am UTC](https://forum.juce.com/t/tabs-not-showing-in-tabbedcomponents-subclass/17077/3 "2016-04-03T06:29:38Z")

</div>

Thanks for your attempt to help.

I've tried all of the combinations like i.e. new Component(), a component that is a&nbsp;&nbsp;static member of the class, ScopedPointer\<TabbedButton\>&nbsp;, nullptr, 0, ...etc.... . None of these&nbsp;work, but even if it worked, it shouldn't be considered a solution, &nbsp;but rather, a temporary hack. &nbsp;If "giving it a component" (as you kindly advised)&nbsp;instead of nullptr or 0 &nbsp;changed the situation, it still would be&nbsp;a problem of robustness of the TabbedComponent class.&nbsp;

I fail to see why giving nullptr or 0 should result in tab not being displayed... tab is just a tab... whether it contains any nested components or not.&nbsp;

Finally, if you use Introjucer to nest&nbsp;a TabbedComponent in&nbsp;another component, the addTab() calls use &nbsp;0-es (not even nullptrs) as arguments and it works fine...

&nbsp;

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [April 3, 2016, 7:31am UTC](https://forum.juce.com/t/tabs-not-showing-in-tabbedcomponents-subclass/17077/4 "2016-04-03T07:31:51Z")

</div>

A class like TabbedComponent does a whole bunch of essential stuff in many methods like resized() etc. If you override them, then of course the base class won't work properly!

You really shouldn't be inheriting from TabbedComponent unless you're an expert. There's generally no reason to do so, you can just create one and use it.

---

<div class="post-metadata">

**Author:** ![appjuce](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@appjuce](https://forum.juce.com/u/appjuce)\
**Post date:** [April 3, 2016, 10:36pm UTC](https://forum.juce.com/t/tabs-not-showing-in-tabbedcomponents-subclass/17077/5 "2016-04-03T22:36:24Z")

</div>

Thanx Jules; that was a good hint.. :-) It works as expected...
