Label prefHeight vs wrapText
lehmann at media-interactive.de
Wed May 28 16:10:51 UTC 2014
thanks for the explanation. Feels good to finally understand this ;-)
And while I created a ticket as per your suggestion...
[#RT-37309] VBox: vshrink layout hint similar to vgrow
...it seems I can use this as a workaround:
> () -> label1.prefHeight(vbox.getWidth()),
Maybe something similar could be made available per label boolean
property. So basically the ability to ask a label to consider wrapping
when calculating its minHeight... I can imagine that this might have
made more sense as a default behavior: if people explicitly ask for
wrapping text, they would probably accept a larger minHeight.
On 28.05.2014 16:17, Martin Sladecek wrote:
> Hi Werner,
> the important min/pref/max height is the one with width parameter as
> Label is horizontally biased. So while minHeight(width) == 17,
> prefHeight(width) == 34.
> But in your case, with ListView's prefHeight == 1000, you'll overflow by
> over 400px. VBox does evenly subtract these overflow pixels from
> children until it gets to their minimum. Which happens in case of the Label.
> Vgrow is ignored when shrinking (see javadoc for setVgrow). Currently,
> neither VBox nor GridPane allow you define policy for children when the
> pane is below it's pref size and children need to be shrunk. Seems like
> a good candidate for a Tweak in JIRA. ;-)
> If you need to keep your Label at some height, currently you can only
> raise it's minHeight, but I understand that in this case it may be
> tricky as it depends on the width.
More information about the openjfx-dev