RFR: 8372530: Easier placement of windows with positioning anchor

Michael Strauß mstrauss at openjdk.org
Wed Dec 10 00:08:19 UTC 2025


On Mon, 8 Dec 2025 23:28:16 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

>> 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?

Maybe we can specify two anchors:

void Stage.relocate(AnchorPoint screenAnchor, AnchorPoint stageAnchor);


Then, if you want to center the window on the screen, you can do:

myStage.relocate(AnchorPoint.proportional(0.5, 0.5), AnchorPoint.proportional(0.5, 0.5));
// or myStage.relocate(AnchorPoint.CENTER, AnchorPoint.CENTER);

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

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


More information about the openjfx-dev mailing list