# Button disappears on resize

**URL:** <https://forum.juce.com/t/button-disappears-on-resize/31277>\
**Category:** General JUCE discussion\
**Created:** [January 14, 2019, 4:56pm UTC](https://forum.juce.com/t/button-disappears-on-resize/31277 "2019-01-14T16:56:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![udirub](https://avatars.discourse-cdn.com/v4/letter/u/e79b87/32.png) [@udirub](https://forum.juce.com/u/udirub)\
**Post date:** [January 14, 2019, 4:56pm UTC](https://forum.juce.com/t/button-disappears-on-resize/31277/1 "2019-01-14T16:56:30Z")

</div>

Hi All,  
I’m new to JUCE and I’m trying to work with a FlexBox.  
I created a new GUI project and added a text button to the main component and I’m trying to use a FlexBox for the layout (obviously, I’ll add more controls later, it’s not just for the button 🙂 ).  
It appears to work fine when the app starts but when I try to resize the window the button just disappears!  
What am I missing?

Here is my code:

```
MainComponent::MainComponent() 
{
    setSize (600, 400);

    _saveButton.setButtonText("Save");
    _saveButton.changeWidthToFitText(30);
    addAndMakeVisible(_saveButton);
    _saveButton.onClick = std::bind(&MainComponent::onSaveButtonClick, this);
}

void MainComponent::onSaveButtonClick()
{

}

void MainComponent::paint (Graphics& g)
{
    // (Our component is opaque, so we must completely fill the background with a solid colour)
    g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));

}

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.
    auto r = getLocalBounds();

    FlexBox sidebar;
    sidebar.items.add( _saveButton );

    sidebar.performLayout(r);
}
```

---

<div class="post-metadata">

**Author:** ![matkatmusic](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@matkatmusic](https://forum.juce.com/u/matkatmusic)\
**Post date:** [January 15, 2019, 9:00am UTC](https://forum.juce.com/t/button-disappears-on-resize/31277/2 "2019-01-15T09:00:25Z")

</div>

You need to specify the FlexBox parameters.

see this constructor  
[https://docs.juce.com/master/classFlexBox.html#a4c44bc8d44580b62d02e42ee4b53b9d5](https://docs.juce.com/master/classFlexBox.html#a4c44bc8d44580b62d02e42ee4b53b9d5)
