GUI button not visible

Hello. I’ve created my first application. I’ve used Projucer -> New Project -> GUI application
And wrote following code, but my buttons are not visible.

    : myButton("My Button")
    setSize (500, 500);

in MainContentComponent::~MainContentComponent()

if(! myButton.isDown()) myButton.setEnabled(false);

in MainContentComponent::resized()

myButton.setBounds(margin, getHeight() /2 , getWidth() + 35, 35);
// also tried BoundsRelative

MainContentComponent::paint is empty

What am i missing?

I’m not sure you understand what a destructir is. Ie. None of the things you are doing in ~MainContentComponent will have any effect on making your button visible, because that function is executed when the MaonContentComponent is destroyd.

As well, the button you reference in resize is not myButton

oh yeah i forgot to change button name, but still same

The code does not belong in the destructor

1 Like

Did you see the GUI tutorials? Maybe it will help you to follow them and then modify them.
Just a quick thought: Are you sure that the coordinates you pass to myButton.setBounds are inside the MainContentComponents bounds? getHeight()/2 should work, but what’s the value of margin?