On 28.5.2014 18:10, Werner Lehmann wrote:
Martin,
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
Thanks!
...it seems I can use this as a workaround:
label1.minHeightProperty().bind(Bindings.createDoubleBinding(
() -> label1.prefHeight(vbox.getWidth()),
vbox.widthProperty()));
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.
Probably a property would be better since it doesn't change the behavior
(and Labeled is all over the controls). It calls for a 3-state property
(no wrapping, wrapping only when space available, wrapping), but it's
too late for that unfortunately. Anyway, looks like we have another
candidate for JIRA ;-)
-Martin
Werner
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.
-Martin