Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8089489

[Stage] Minimize then maximize can switch screens in dual monitor setup

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8u40
    • Fix Version/s: tbd
    • Component/s: javafx
    • Labels:
    • Environment:

      java version "1.8.0_40-ea"
      Java(TM) SE Runtime Environment (build 1.8.0_40-ea-b09)
      Java HotSpot(TM) 64-Bit Server VM (build 25.40-b13, mixed mode)

      Description

      In an app that I am working on, running on a dual monitor setup, I notice that the main window can switch from one screen to the other when minimized and maximized (at least on Windows 7). I reduced this to the following minimal test case (read the comments in the code for instructions):

      import javafx.application.Application;
      import javafx.collections.ObservableList;
      import javafx.geometry.Rectangle2D;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.layout.BorderPane;
      import javafx.stage.Screen;
      import javafx.stage.Stage;

      /**
       * This is a minimal test app for an issue I am seeing in a much larger application that I am working on
       * related to a dual monitor setup.
       *
       * This program reproduces an issue for me on Windows 7, and JDK 8u40 b09. Run the program and the app window
       * should be maximised on the *secondary* screen. Click the icon in the Windows taskbar to minimise the app,
       * then click again to maximise. The app is now maximised but has switched to the primary screen.
       *
       * Note the line stage.setMaximized(true) - if you comment this out, the issue goes away.
       */
      public class DualMonitorTest extends Application {
         
          public static void main(String[] args) {
              launch(args);
          }
       
          @Override
          public void start(Stage stage) {
              stage.setTitle("Dual Monitor Test");
              stage.setResizable(true);
              stage.setMaximized(true); // comment out this line and there is no issue

              BorderPane bp = new BorderPane();
              bp.setCenter(new Button("Imagine that clicking this button gives pay increases to the JavaFX team ... in fact, it does nothing."));
              Scene scene = new Scene(bp);
              stage.setScene(scene);
              stage.show();
              ObservableList<Screen> screens = Screen.getScreens();
              Rectangle2D bounds = screens.get(1).getVisualBounds();
              stage.setX(bounds.getMinX());
              stage.setY(bounds.getMinY());
              stage.setWidth(bounds.getWidth());
              stage.setHeight(bounds.getHeight());
          }

      }

        Attachments

        1. log_with_maximizing.txt
          4 kB
          Elina Kleyman
        2. log_without_maximizing .txt
          3 kB
          Elina Kleyman

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              dgilbertjfx David Gilbert (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported: