This content has been marked as final. Show 2 replies
1) Yes, this is expected!
2) Yes, why.. well I don't know why the minimum height of a TextField is smaller than the pref size.
3) This can be avoid by setting your own sizes (min size - pref size - max size)
Edited by: FXdude on 21-jan-2013 6:13
VBox root = new VBox(10); root.setStyle("-fx-background-color: lightgray"); TextField tf = new TextField(); tf.setMinHeight(Control.USE_PREF_SIZE); //the minimum height = the preferred height TextArea ta = new TextArea(); ta.setMinHeight(30); ta.setPrefHeight(50); ta.setMaxHeight(Double.MAX_VALUE); //maximum height, depends on the parent VBox.setVgrow(ta, Priority.ALWAYS); //use the maximum height available root.getChildren().addAll(tf, ta); Scene scene = new Scene(root, 300, 250);
It seems that this:
is sufficient for the TextField to behave properly.
I would expect that to be identical to:
but the latter doesn't work.
What is the meaning of USE_PREF_SIZE? The documentation describes it as:
What's a "sentinel value"?
Sentinel value which can be passed to a control's setMinWidth(), setMinHeight(), setMaxWidth() or setMaxHeight() methods to indicate that the preferred dimension should be used for that max and/or min constraint.