JavaFX Label word wrap with rescaling
Question
Consider the following: a BorderPane
with a VBox
in the center and a ListView
on the left. The ListView
has a fixed (preferred) width. In the center VBox
there are a bunch of Label
s with text. I've chosen for this UI because I want the Label
s to resize with the Stage
(or thus Scene
), so I placed them in the center of a BorderPane
. However, this allows the children to take up their preferred size, which for a Label
means it grows with its textProperty
. This implies the Label
s grow too much and extend over the left part of the BorderPane
. Adding the left part after the center part (first setCenter
then setLeft
) or the other way around doesn't make a difference.
What I want is that the Label
s automatically scale with the Stage
but upon becoming too small for the text to be on one line, wrap the text (for which I use setTextWrap(true)
). However, it seems I need to set the Label
s max with, but that would prevent them from resizing with the Stage
. How can I best fix this?
No correct solution