# Layout does not automatically adjust. What can I do?

**URL:** <https://racket.discourse.group/t/layout-does-not-automatically-adjust-what-can-i-do/3887>\
**Category:** Questions & Answers\
**Created:** [August 6, 2025, 1:18pm UTC](https://racket.discourse.group/t/layout-does-not-automatically-adjust-what-can-i-do/3887 "2025-08-06T13:18:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hnmdijkema](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/hnmdijkema/32/2629_2.png) [@hnmdijkema](https://racket.discourse.group/u/hnmdijkema)\
**Post date:** [August 6, 2025, 1:18pm UTC](https://racket.discourse.group/t/layout-does-not-automatically-adjust-what-can-i-do/3887/1 "2025-08-06T13:18:09Z")

</div>

Hi,

I've got following code (as a spike):

```scheme
(require racket/gui)

(define win (new frame% [label "Hi there!"]))
(define grid-group (new group-box-panel% [label "My group"] [parent win] [horiz-margin 10] [vert-margin 10]))

(define g1 (new horizontal-pane% [parent grid-group]))
(define g1-1 (new horizontal-pane% [alignment '(left center)] [parent g1] [min-width 200]))
(define g1-2 (new horizontal-pane% [alignment '(left center)] [parent g1] [min-width 300]))
(define g1-3 (new horizontal-pane% [alignment '(center center)] [parent g1] [min-width 100]))

(define btn1 (new button% [parent g1-1] [label "Button 1"]
                  [callback (lambda (b e)
                              (send lbl1 set-label "New label")
                              ;(send g1 reflow-container)
                              ;(send g1-3 container-flow-modified)
                              )]))
(define gg1 (new gauge% [parent g1-2] [stretchable-width #t] [label "gauge 1"] [range 100]))
(define lbl1 (new message% [parent g1-3] [label "This is lbl 1 and long"]))

(define g2 (new horizontal-pane% [parent grid-group]))
(define g2-1 (new horizontal-pane% [alignment '(left center)] [parent g2] [min-width 200]))
(define g2-2 (new horizontal-pane% [alignment '(left center)] [parent g2] [min-width 300]))
(define g2-3 (new horizontal-pane% [alignment '(center center)] [parent g2] [min-width 100]))

(define btn2 (new button% [parent g2-1] [label "Btn 2"]))
(define g2-lbl (new message% [parent g2-2] [label "This is something else then a gauge"]))
(define lbl2 (new message% [parent g2-3] [label "This is lbl 2"]))

(define g3 (new horizontal-pane% [parent grid-group]))
(define g3-1 (new horizontal-pane% [alignment '(left center)] [parent g3] [min-width 200]))
(define g3-2 (new horizontal-pane% [alignment '(left center)] [parent g3] [min-width 300]))
(define g3-3 (new horizontal-pane% [alignment '(center center)] [parent g3] [min-width 100]))

(define btn3 (new button% [parent g3-1] [label "Btn 3"]
                  [callback (lambda (b e) (send lbl3 set-label "Longer label now"))]))
(define g3-lbl (new message% [parent g3-2] [label "This is something else then a gauge, another message"]))
(define lbl3 (new message% [parent g3-3] [label "short"]))

(send win show #t)

```

It results in the following window:

 ![afbeelding](https://global.discourse-cdn.com/free1/uploads/racket/original/2X/c/cf7b73b48447555ca149e85182225d0b4f2d438d.png)

As can be seen, the labels on the right are centered. This is as expected.  
Now, when I push 'Button 1', the label on the right will change to "New label".

 ![afbeelding](https://global.discourse-cdn.com/free1/uploads/racket/original/2X/9/9a1bb4db0521d99cbcdd2b8d42a5b15c39881dad.png)

What happens here? The label is not centered anymore, while the horizontal alignment of the containing horizontal-pane% is 'center.

When I push 'Btn3', the short label is changed to "Longer label now". And that looks like this:

 ![afbeelding](https://global.discourse-cdn.com/free1/uploads/racket/original/2X/7/73d2bcd09d73b9620dae308a01ce320a4b6f6b25.png)

So, the "Longer label..." is displayed, but not centered.

What am I missing here?

Thanks in advance for your answers.

---

<div class="post-metadata">

**Author:** ![hnmdijkema](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/hnmdijkema/32/2629_2.png) [@hnmdijkema](https://racket.discourse.group/u/hnmdijkema)\
**Post date:** [August 6, 2025, 9:00pm UTC](https://racket.discourse.group/t/layout-does-not-automatically-adjust-what-can-i-do/3887/2 "2025-08-06T21:00:32Z")

</div>

Replying to myself. Apparently there is an option 'auto-resize' for message%. This already helps a lot. But is there a generic solution, also applicable for other widgets?

E.g. check-box%.
