Marco Canora
Marco Canora

Reputation: 335

JavaFX sizes doubts

If I have a window with a BorderPane and its size properties are:

Why can I resize the window? I haven't clear how works these properties (I read the API and I still don't understand).

Upvotes: 0

Views: 52

Answers (1)

James_D
James_D

Reputation: 209330

The min/max/pref width and height of a Region are used by a parent layout pane to determine how to size and position the child nodes of that pane. So if you put your border pane in a parent which manages layout (i.e. a subclass of Pane), then those settings would be adhered to, if possible.

However, a Scene is not a layout pane and basically performs no layout. It has one root node (a Parent instance), and simply sizes the root to the size of the Scene. In turn, the scene is sized by the window and takes on the size of the window minus any space needed for a window border and decorations.

Consequently, these settings on your BorderPane have no effect on the resizability of the window. To turn off the ability to resize the window, use the window method setResizable(false). Similarly, if you want to impose minimum or maximum sizes on the window, use the window's min/max width/height properties.

Upvotes: 2

Related Questions