Label prefHeight vs wrapText

Werner Lehmann lehmann at
Wed May 28 13:44:36 UTC 2014


I am stumped. With a label and wrapText=true I am not getting wrapped 
text when I think I should. Consider this scene (code at bottom):

   - Label, long text, wrapText=true
   - ListView, prefHeight=1000 (too big to fit)

This will not wrap the label text. The VBox gives all room to the 
listview and keeps the label on a single line. VBox.vgrow does not 
change this.

Without the prefHeight on the listview I am getting wrapped text. Then, 
label height is 34 - while its min/pref/max height is all at 17 
according to ScenicView.

Why is the label not reporting a pref height of 34?
Why is the vbox sizing the label beyond its max height?

Appreciate any insight because I don't see what's going on.


public class WrapTest extends Application
   public static void main(String[] args)

   public void start(Stage primaryStage) throws Exception
     Label label1 = new Label(Strings.repeat("bla ", 50));

     ListView<String> lv = new ListView<String>();

     VBox vb = new VBox(label1, lv);
     Scene scene = new Scene(vb, 800, 600);

More information about the openjfx-dev mailing list