JDK-8091771 : Provide a way to position stage depending on its size before actually showing it on the screen
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: scenegraph
  • Affected Version: 8
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2013-04-19
  • Updated: 2018-09-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
for the following sequence (attached):

        stage.sizeToScene();
        System.out.println(String.format("before: %.0fx%.0f", stage.getWidth(), stage.getHeight()));
        stage.show();
        System.out.println(String.format("after: %.0fx%.0f", stage.getWidth(), stage.getHeight()));

I get the following output:

before: NaNxNaN
after: 216x238

I need to know stage size before I actually show it to position it correctly. Although it can be achieved by listening to width and height properties, this seems to be overkill for such a simple task.
Comments
One possibility might be supporting anchorX, anchorY and anchorLocation in Window (currently used in PopupWindow).
30-10-2013

Although this particular request could be considered as not an Issue, the problem still persist. There should be a way to get stage size and position it properly prior to showing it on the screen. So I'm reopening this as a feature request. Any ideas how this could be implemented?
30-10-2013

In addition to that, on some systems, the size of the window decorations is unknown until the window is displayed. Native functions which get that size before the window is displayed return estimates only and their usage is discouraged.
23-10-2013

The stage size computing needs to happen in the lower layers (is platform-dependent) and we can't sync the needed values at arbitrary point of time, it happens in pulse, so I'm not sure it'll be possible to fix this. Assigning to Lubo for deeper evaluation.
30-04-2013