<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Small addition; the 3520 button moved the top left of the Window
      to the middle of the right screen, but the window as a whole was
      not centered.</p>
    <p>--John<br>
    </p>
    <div class="moz-cite-prefix">On 09/04/2025 13:22, John Hendrikx
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:f75da401-6d70-4530-a7ce-c1be8423fd6d@gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <p>Hi Thiago,</p>
      <p>I ran this on Windows.  My monitor setup is:</p>
      <p>Left: 3840x2160 (150%) -- top left coordinate (-2560, 0) (-2560
        because of scaling)<br>
        Middle: 3840x2160 (150%) -- this one has a top left coordinate
        of (0, 0)<br>
        Right: 1920x1200 (100%) -- this one has a top left coordinate of
        (2560, 0)<br>
      </p>
      <p>When started, the program appeared perfectly centered on the
        middle screen.</p>
      <p>Your program showed buttons: 4480 and 3520</p>
      <p>The 4480 button moved the Window far too the right, off screen
        and I had to stop the program</p>
      <p>The 3520 button moved the Window to the Right monitor, but it
        was not centered nicely.</p>
      <p>I added a `peek(System.out::println)` on the screens stream. 
        These are my screens:</p>
      <div style="background-color:#ffffff;padding:0px 0px 0px 2px;">
        <div
style="color:#000000;background-color:#ffffff;font-family:"Consolas";font-size:11pt;white-space:pre;"><p
        style="margin:0;"><span style="color:#0000ff;">Rectangle2D [minX=0.0, minY=0.0, maxX=2560.0, maxY=1440.0, width=2560.0, height=1440.0]</span></p><p
        style="margin:0;"><span style="color:#0000ff;">Rectangle2D [minX=2560.0, minY=-194.0, maxX=4480.0, maxY=1006.0, width=1920.0, height=1200.0]</span></p><p
        style="margin:0;"><span style="color:#0000ff;">Rectangle2D [minX=-2560.0, minY=6.0, maxX=0.0, maxY=1446.0, width=2560.0, height=1440.0]</span></p></div>
      </div>
      <p>--John<br>
      </p>
      <div class="moz-cite-prefix">On 09/04/2025 12:55, Thiago Milczarek
        Sayão wrote:<br>
      </div>
      <blockquote type="cite"
cite="mid:CAAP_wu=F8us2SfaYgx6YQgzzwGNHFgtjzW0cEsLZPQp5-f7wmw@mail.gmail.com">
        <meta http-equiv="content-type"
          content="text/html; charset=UTF-8">
        <div dir="ltr">Hi,
          <div><br>
          </div>
          <div>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!</div>
          <div>
            <div
class="gmail-text-base gmail-my-auto gmail-mx-auto gmail-py-5 gmail-[--thread-content-margin:--spacing(4)] gmail-@[37rem]:[--thread-content-margin:--spacing(6)] gmail-@[70rem]:[--thread-content-margin:--spacing(12)] gmail-px-(--thread-content-margin)">
              <div
class="gmail-[--thread-content-max-width:32rem] gmail-@[34rem]:[--thread-content-max-width:40rem] gmail-@[64rem]:[--thread-content-max-width:48rem] gmail-mx-auto gmail-flex gmail-max-w-(--thread-content-max-width) gmail-flex-1 gmail-text-base gmail-gap-4 gmail-md:gap-5 gmail-lg:gap-6 gmail-group/turn-messages gmail-focus-visible:outline-hidden"
                tabindex="-1">
                <div
class="gmail-group/conversation-turn gmail-relative gmail-flex gmail-w-full gmail-min-w-0 gmail-flex-col gmail-agent-turn">
                  <div
class="gmail-relative gmail-flex-col gmail-gap-1 gmail-md:gap-3">
                    <div class="gmail-flex gmail-justify-start">
                      <div
class="gmail-touch:-me-2 gmail-touch:-ms-3.5 gmail--ms-2.5 gmail--me-1 gmail-flex gmail-items-center gmail-p-1 gmail-select-none gmail--mt-1 gmail-duration-[1.5s] gmail-focus-within:transition-none gmail-hover:transition-none gmail-pointer-events-none gmail-[mask-image:linear-gradient(to_right,black_33%,transparent_66%)] gmail-[mask-position:100%_0%] gmail-[mask-size:300%_100%] gmail-motion-safe:transition-[mask-position] gmail-group-hover/turn-messages:pointer-events-auto gmail-group-hover/turn-messages:[mask-position:0_0] gmail-group-focus-within/turn-messages:pointer-events-auto gmail-group-focus-within/turn-messages:[mask-position:0_0] gmail-has-data-[state=open]:pointer-events-auto gmail-has-data-[state=open]:[mask-position:0_0]"><span
                          class="gmail-"></span></div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div><br>
            </div>
            <div>On Ubuntu 24.04 the first button moves the Stage to the
              end of the first screen (bit weird). </div>
            <div>The second work as expected, it gets moved to the start
              of the center of the last screen.</div>
            <div><br>
            </div>
            <div>Thanks!</div>
            <div><br>
            </div>
            <div>
              <div
style="background-color:rgb(30,31,34);color:rgb(188,190,196)">
                <pre
style="font-family:"JetBrains Mono",monospace;font-size:9.8pt"><span
                style="color:rgb(207,142,109)">import </span>javafx.application.Application;
<span style="color:rgb(207,142,109)">import </span>javafx.geometry.Pos;
<span style="color:rgb(207,142,109)">import </span>javafx.geometry.Rectangle2D;
<span style="color:rgb(207,142,109)">import </span>javafx.scene.control.Button;
<span style="color:rgb(207,142,109)">import </span>javafx.scene.layout.VBox;
<span style="color:rgb(207,142,109)">import </span>javafx.stage.Screen;
<span style="color:rgb(207,142,109)">import </span>javafx.stage.StageStyle;
<span style="color:rgb(207,142,109)">import </span>javafx.application.Platform;
<span style="color:rgb(207,142,109)">import </span>javafx.scene.Scene;
<span style="color:rgb(207,142,109)">import </span>javafx.scene.layout.StackPane;
<span style="color:rgb(207,142,109)">import </span>javafx.scene.paint.Color;
<span style="color:rgb(207,142,109)">import </span>javafx.stage.Stage;

<span style="color:rgb(207,142,109)">import </span>java.util.Comparator;

<span style="color:rgb(207,142,109)">public class </span>TestScreenBounds <span
                style="color:rgb(207,142,109)">extends </span>Application {

    @Override
    <span style="color:rgb(207,142,109)">public void </span>start(Stage stage) {
        stage.setTitle(<span style="color:rgb(106,171,115)">"Move Outside Bounds"</span>);
        Rectangle2D bounds = Screen.getScreens().stream()
                .map(Screen::getBounds)
                .sorted(Comparator.comparingDouble(Rectangle2D::getMaxX).reversed())
                .findFirst()
                .orElseThrow();

        Button btn = <span style="color:rgb(207,142,109)">new </span>Button(<span
                style="color:rgb(106,171,115)">"Move To " </span>+ bounds.getMaxX());
        btn.setOnAction(event -> stage.setX(bounds.getMaxX()));

        <span style="color:rgb(207,142,109)">double </span>middleLastScreen = bounds.getMinX() + bounds.getWidth() / <span
                style="color:rgb(42,172,184)">2</span>;

        Button btn2 = <span style="color:rgb(207,142,109)">new </span>Button(<span
                style="color:rgb(106,171,115)">"Move To " </span>+ middleLastScreen);
        btn2.setOnAction(event -> stage.setX(middleLastScreen));

        VBox root = <span style="color:rgb(207,142,109)">new </span>VBox(btn, btn2);
        root.setFillWidth(<span style="color:rgb(207,142,109)">true</span>);
        root.setAlignment(Pos.CENTER);
        Scene scene = <span style="color:rgb(207,142,109)">new </span>Scene(root, <span
                style="color:rgb(42,172,184)">300</span>, <span
                style="color:rgb(42,172,184)">300</span>);
        stage.setScene(scene);
        stage.show();
    }

    <span style="color:rgb(207,142,109)">public static void </span>main(String[] args) {
        launch(TestScreenBounds.<span style="color:rgb(207,142,109)">class</span>, args);
    }
}

</pre>
              </div>
            </div>
          </div>
        </div>
      </blockquote>
    </blockquote>
  </body>
</html>