Hi All,

I’m a newbie in Juce and trying to expand my skills on this great tool, but I am facing so many dificulties that is making this task hard for me.
I wish there were more examples, diferent type of examples, so we could see JUCE in action and the way it can be used for many diferent situations.
I know that JUCE demo already shows an overall of the possibilities we have with JUCE, but my doubts mainly are in the way we can use it to operate with diferent situations.
I believe that this dificulties are also because I’m not an experienced C++ developer, I have skills in other languages, and since I found this great framework, i need to expand my horizons.

I wish that there is someone that can help me to solve this tasks, that i believe they should be easy, but for me, they are huge tasks. If possible with examples was great.

What I’m trying to do and unable to do it with success:

  • I have on main window that will open diferent components, each component will act as a tabbed window in the main window.
  • Each of this component will have buttons and and other widgets that will have listeners inside each component, to create interaction within each component.
  • To show each component I use “addAndMakeVisible” function.

My problem is:

  • Inside one component i need to have one option like close or change view, that will need to show other component;
  • From main window, i need to know if a specific button inside the component was clicked, and in case it was, to have actions associated with it.
  • How to move from one component to other directly.

I believe this are basic actions but for me, hard to do it.

It was great if anyone could help me on this.

Thanks for your precious time,
Paulo Vaz


Try looking at this in conjunction with the introjucer source . .



Dear Billythekid,

thanks for your reply, but honestly i could not understand the way to use it in my project for my needs.

Can you help me on more concrete way.

How to create commands in the main window and how to call them in a component window ?

Thanks in advance,


Take a simple example where you want to show a Component (a) using another Component (b) that is in front of the occluded component. These components exist as children of a mother component ©.

Within c, add a public member that makes a call to a->toFront(true). Pass a pointer to c into the constructor for b, then in the button callback within b, you can invoke the method in c using the pointer that you passed in.


Hi Billy,

here are some parts of my code:

I have a MainWindow with a function like JuceDemo:

void showTab (Component* showComp)
currentComp = showComp;
addAndMakeVisible (currentDemo);

I have declared in the private section:

ScopedPointer currentComp;

In this case i call a component that in reality is a page of my application, in the MainWindow i call it using “showTab(createFrontPage())”.

FrontPage is one of the components i use.

in my component FrontPage i declare it this way:

Component* createFrontPage()
return new FrontPageComponent();

In my FrontPage Component i have a button that needs to call the father function on MainWindow showTab to show another component.

I know this is basic questions but is was great if you could help me to bypass this.

I can give more parts of code if necessary.



Ah, ok. You’re doing it like that. The example I gave above assumed that the sub-component lifecycle was tied in with the parent window. What you’re doing is using a ScopedPointer to hold the currently visible component, destroying it when a new component is made visible. No problem. You just need to supply a parent-component pointer to your FrontPageComponent ctor.

There are lots of ways to do this, and a problem with the simple method I mention above is that you are dispersing your component creation logic among your different components. Using a CommandManager will allow you to put this logic in one place. You can then easily trigger the commands from button presses.


Thanks again.

I made the modification but gives me the error sayin ‘createFrontPage’ : Function does not take 1 arguments.

Seems i should modify my Component also.

And how can i call my function from the child component “createFrontPage”.

I’m doing this way, because i want to build one application that have several screen with diferent functions. But i need to be able to change from one screen to another.

And i want to devide the functions by components.

Thanks for your time.

class Parent : public Component
    ScopedPointer<Component> child;

    Component* createA()
        return new ChildA(this);

    Component* createB()
        return new ChildB(this);

    void showTheStuff(Component* c)
        addAndMakeVisible(child = c);

Then from the child . . .

class ChildA : public Component
Parent* parent;

     ChildA(Parent* parent_) : parent(parent_) {}
    void someCallbackWhatever()
         parent->showTheStuff(  parent->createB()  );

OK? Probably full of typos but hopefully it gives the picture of what I think you’re trying to achieve . . .

Even better would be to supply the child components with a lambda that performs the callback operation you want performing [parent->showTheStuff( parent->createB() );]. This would reduce the coupling between child and parent components. The child component would then only need to take a generic callback function as a ctor argument, probably making life easier down the line.


tried it, but gives many errors !

oh my GOD.

Can I send you my project, it’s simple lines of core until now, and you see what i am making wrong ?



If it is tiny, put it on GitHub, post a link and maybe someone will point to any major sins.


Thank you for your advices.