Hi,

right now, I am doing this to prevent stage windows to be resizable in
a way that cuts off their contained scene's content:

        final Scene scene = new Scene(pane);
        stage.setScene(scene);
        stage.setTitle(getClass().getSimpleName());
        stage.sizeToScene();

        // ensure that the window can not be resized to smaller than
the minsize of its scene
        Runnable updateMinSize = () -> {
            stage.setMinWidth(scene.getRoot().minWidth(scene.getHeight()));
            stage.setMinHeight(scene.getRoot().minHeight(scene.getWidth())
+ DECORATIONS_HEIGHT);
        };

        stage.setOnShown((e) -> updateMinSize.run());
        stage.widthProperty().addListener((obs, oldVal, newVal) ->
updateMinSize.run());
        stage.heightProperty().addListener((obs, oldVal, newVal) ->
updateMinSize.run());
        stage.show();

This feels somewhat odd (and the constant for window decoration's
height is ugly but maybe I am missing the clean way to retrieve it)
for something that should be a common requirement (in all of our
applications it is usually considered a bug when a window/dialog does
not enforce this).

Shouldn't there be a method like
stage.setRespectContentMinSize(boolean respect) or something similar?
Am I missing something obvious that is already there?

Thanks for any insights.

Robert

Reply via email to