Help test the behavior of a multi-screen setup with both Mac and Windows

Andy Goryachev andy.goryachev at oracle.com
Wed Apr 9 14:27:33 UTC 2025


I've got Mac with one (or possibly two) external monitors.  I'll test and report later today.

-andy


From: openjfx-dev <openjfx-dev-retn at openjdk.org> on behalf of Thiago Milczarek Sayão <thiago.sayao at gmail.com>
Date: Wednesday, April 9, 2025 at 03:56
To: openjfx-dev <openjfx-dev at openjdk.org>
Subject: Help test the behavior of a multi-screen setup with both Mac and Windows
Hi,

Could anyone with a multi-screen setup on Mac and/or Windows please share the results of the two buttons on this sample app? Your feedback would be greatly appreciated!

On Ubuntu 24.04 the first button moves the Stage to the end of the first screen (bit weird).
The second work as expected, it gets moved to the start of the center of the last screen.

Thanks!


import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.geometry.Rectangle2D;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.stage.Screen;
import javafx.stage.StageStyle;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

import java.util.Comparator;

public class TestScreenBounds extends Application {

    @Override
    public void start(Stage stage) {
        stage.setTitle("Move Outside Bounds");
        Rectangle2D bounds = Screen.getScreens().stream()
                .map(Screen::getBounds)
                .sorted(Comparator.comparingDouble(Rectangle2D::getMaxX).reversed())
                .findFirst()
                .orElseThrow();

        Button btn = new Button("Move To " + bounds.getMaxX());
        btn.setOnAction(event -> stage.setX(bounds.getMaxX()));

        double middleLastScreen = bounds.getMinX() + bounds.getWidth() / 2;

        Button btn2 = new Button("Move To " + middleLastScreen);
        btn2.setOnAction(event -> stage.setX(middleLastScreen));

        VBox root = new VBox(btn, btn2);
        root.setFillWidth(true);
        root.setAlignment(Pos.CENTER);
        Scene scene = new Scene(root, 300, 300);
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(TestScreenBounds.class, args);
    }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20250409/0725aca5/attachment-0001.htm>


More information about the openjfx-dev mailing list