resizing of window

Jose Martinez jmartine_1026 at yahoo.com
Tue Jun 26 20:47:14 PDT 2012


Noticed a bug in how the scene's dimensions were being calculated...

        scene = new Scene(root, WIDTH * (1 + scaleFactor * .1), HEIGHT * ( 1 + scaleFactor * .1));//...where scaleFactor is an integer
vs. 
        scene = new Scene(root, WIDTH * (1 + scaleFactor * 100), HEIGHT * (1 + scaleFactor * 64));//...very wrong way


....either way the window still does not change size when I apply the scene to the Stage and change the Stage's dimensions.

thanks
jose


________________________________
 From: Jose Martinez <jmartine_1026 at yahoo.com>
To: openjfx mailing list <openjfx-dev at openjdk.java.net> 
Sent: Tuesday, June 26, 2012 9:15 PM
Subject: resizing of window
 
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());
        stage.show();
    }


thanks
jose


More information about the openjfx-dev mailing list