Total noob question: one component is taking up whole window

Hey all,

So, I’ll come right out and say I’m a total noob to this; my background is in web-based guis designed with html and powered by javascript/perl
I read through the tutorial here ( ) but it seems to be very very out of date, so i’m not sure how much of it is still applicable.

I’m trying to write a “hello world” app so to speak, and I want to make a button and a text label.

I’m able to compile my app and get either a button or a text label to appear in the window, but not both. I think this is because the second ui element I am declaring is being rendered on top of the other one because I am not setting its size correctly. I’ve tried using setBounds, and setBoundsRelative, but neither appear to have any effect on the rendered element.

When I only render a button, the button stretches to fit the entire window. When I resize said window, it resizes as well and fills up the entire thing.

Here’s the code in my MainWindow.cpp (not sure if it’s relevant but I’m using mac os 10.6.8 and xcode to compile.)


This file was auto-generated by the Jucer!

It contains the basic outline for a simple desktop window.


#include “MainWindow.h”

: DocumentWindow (JUCEApplication::getInstance()->getApplicationName(),
TextButton *button1 = new TextButton (T(“Hello world!”));
button1->setBoundsRelative(0.2f, 0.2f, 0.5f, 0.5f);
setContentOwned (button1, false);

centreWithSize (320, 480);
setVisible (true);



void MainAppWindow::closeButtonPressed()


Thanks in advance for any insight you guys can lend.

You should have a generic Component (or one you’ve designed to be a background) passed into setContentOwned. Then create the button and the label and add them to that component.