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); } }