Maciej Dobrowolski Maciej Dobrowolski - 3 months ago 22
Java Question

AnchorPane keeps growing despite having maxWidth property set

I am building simple GUI where the root element

StackPane
is having two children:
HBox
and
AnchorPane
.

AnchorPane's width is growing

Having set
maxWidth
property for all children components to
600
,
AnchorPane
still seems to grow horizontally when I only add any component to it and set this component's anchor to the value beyond
600
.

As you can see in above screenshot -
Label
in a bottom-right corner has left anchor set to
700
which leads to increase in
AnchorPane
width.

I would rather have this
Label
cut or placed beyond visible space.

Why is that? Can I somehow force
AnchorPane
to keep its maximal bounds? Is there any workaround for this issue?

You can find related java(fx) code here.

Answer

I don't know why but, I tested it in SceneBuilder and changed some properties in fxml and it worked. I added minWidth to StackPane and AnchorPane. This is my fork.

Comments