I have a button that set in center of the screen and one Label that set at top of that button. I am able to do it but Label and button has the 0 margin. i want to set the 10px margin between them.
this is my label attached button
lbllowest.attachToComponent(&buttonA3, false);
use the setBounds() function to position your components.
There are a bunch of helper functions you can use to position them within your parent component’s bounds. JUCE: Component Class Reference Scroll down to where the ‘getX()’ function is and look through the available options.
you’ll do stuff like
auto componentBounds = getLocalBounds();
button1.setBounds(componentBounds.getX() + 10, //left edge + 10 px
componentBounds.getBottom() - preferredHeight,
preferredWidth,
preferredHeight);
//adjacent to button1, with same bounds, and a 10px gap
button2.setBounds( button1.getBounds().withX( button1.getRight() + 10 ) );