RFR: 8372530: Easier placement of windows with positioning anchor

Andy Goryachev angorya at openjdk.org
Wed Dec 10 00:08:19 UTC 2025


On Fri, 28 Nov 2025 00:09:26 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:

>> modules/javafx.graphics/src/main/java/javafx/stage/Stage.java line 1298:
>> 
>>> 1296:     @Override
>>> 1297:     public void centerOnScreen() {
>>> 1298:         relocationRequest = null; // cancel previous relocation request
>> 
>> As far as I understand, with the new anchor system, a center on screen can easily be achieved as well? I wonder if we could also deprecate this method instead. But not sure if I understand it correctly.
>
> No, the anchor is always a point _on the window being shown_, not on the screen. All anchor APIs require you to specify an explicit screen location, and the window is then moved so that the anchor coincides with that screen location. So to emulate `centerOnScreen()`, you'd have to manually get the screen bounds, and then calculate the center.

Is there something that prevents us to invent a new anchor type?

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1986#discussion_r2600499939


More information about the openjfx-dev mailing list