RFR: 8372530: Easier placement of windows with positioning anchor
Michael Strauß
mstrauss at openjdk.org
Wed Dec 10 00:08:20 UTC 2025
On Tue, 9 Dec 2025 16:13:08 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> 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);
>
> I like it, because we can easily cover almost all the possible cases.
>
> Should we also allow to specify the `Screen`? In a third parameter to this extended method? And if the `Screen` is `null`, the logic would use the default screen or the owner's one? What do you think?
I've added another overload that accepts a `Screen`. The overloads _without_ the screen parameter will always refer to the _current_ screen. This allows users to relocate a stage on its current screen as if it was the primary screen (i.e. with `(0, 0)` being the top-left corner).
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1986#discussion_r2604705791
More information about the openjfx-dev
mailing list