Control size of lemur container

I have a Lemur container including only a text field and a button. Because nothing inside the container is very big, the container is far too small. Plus, the container changes size to accommodate the size of the text field.
How can I control the size of the container?

Set its preferred size.

Setting a GUI element’s preferred size overrides all automatic preferred size calculation. It’s often customary to ask the element what it’s preferred size is before setting it just to make sure you create a preferred size that is at least as big… else it can become tricky to add things or restyle them later.

Edit: note that if you ever want an element to return to calculating its own preferred size then set preferred size to null and it will go back to automatically calculating it.

1 Like

Thanks, that is working! :+1:

By the way, how would I center the button in the container (besides manually setting the preferred size and insets, of course)?

button.setInsetsComponent(DynamicInsetsComponent(0.5, 0.5, 0.5, 0.5))?

Edit: the assumption is that it’s growing to the full width of the container now and you’d like it to remain regular sized but otherwise be centered.

1 Like

Yup, that’s what I needed. :ok_hand: