To statically set a window minimum size to a 100x100
pixels frame in JavaFX 2.2 one would use:
stage.setMinWidth(100);
stage.setMinHeight(100);
Supposing we don't want to set a fixed minimum size, but we want the window to be resized to a minimum size that all its content (buttons, text fields, etc.) is still fully visible. How would we do that?
You can try to use stage.minWidthProperty().bind(... Binding expression here...);
The difficulty of course is to define the binding expression... it should depend on all your components but still it should work.
Resizing children will modify the binding expression and will change the minWidthProperty on your Stage.
I suggest you to read the javadoc of Pane
, Region
and maybe Group
nodes. On how they layout and resize their children. Basically if you don't set the preferred size of the pane then, by default, it will be calculated according to its content. Also have a look on Window.sizeToScene() method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With