resizing of window

Pavel Safrata pavel.safrata at
Wed Jun 27 02:08:43 PDT 2012

Window has width and height properties, you can register listeners to them.
With regards,

On 27.6.2012 3:15, Jose Martinez wrote:
> hello,
> I would like to support resizing of my app.  I imagine there are two ways this could be done.
> 1)  Free flow resizing.  Users just change the window to their desired size.  The app's root Parent will scale accordingly to fill in the new window size.  To support this I would need to be notified that the window size has changed and have access to the new window dimensions.  From looking at the Stage and Window classes I do not see any way to register a call back on window resize.  Is there a way to accomplish this?
> 2)  From within the app user selects the window size they want.  This is less ideal but acceptable.  I did some tests and was happy with the performance of the scaled root Parent, but did see flickering and objects disappear (I am not too concerned about this yet because I was doing live scaling changes, versus through an options section from the title screen).  The problem that I did have was that I was not able to change the window size.  I tried using Stage.setHeight/setWidth and Stage.sizeToScene, but the window remained unchanged.  I would first create a new Scene that matched the new dimensions, update my Stage with the new Scene, then change the dimensions of Stage.  Is there a way to change the window size from within the app?
>      private static void resize() {
>          if (scaleFactor > 0) {
>              Scale scale = ScaleBuilder.create().pivotX(0).pivotY(0).x(1 + .1 * scaleFactor).y(1 + .1 * scaleFactor).build();
>              root.getTransforms().setAll(scale);
>          } else {
>              root.getTransforms().clear();
>          }
>          scene = new Scene(root, WIDTH * (1 + scaleFactor * 100), HEIGHT * (1 + scaleFactor * 64));
>          stage.setScene(scene);
>          stage.sizeToScene();
> //state.setHeight(scene.getHeight());
> //state.setWidth(scene.getWidth());
>      }
> thanks
> jose

More information about the openjfx-dev mailing list