resizing of window

Jose Martinez jmartine_1026 at
Tue Jun 26 18:15:25 PDT 2012


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();
        } else {
        scene = new Scene(root, WIDTH * (1 + scaleFactor * 100), HEIGHT * (1 + scaleFactor * 64));


More information about the openjfx-dev mailing list