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

Window order is not correct when Modality.WINDOW_MODAL

    Details

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Ubuntu 18.04

      A DESCRIPTION OF THE PROBLEM :
      When managing multiple windows on our OpenJfx application sometimes a window that was first opened pops on the front of a current window. It happens when there is a modal window.

      We are always sure to initOwner() with the parent window and then set initModality(Modality.WINDOW_MODAL).


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Execute the code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The dialog should be on top.
      ACTUAL -
      The first stage is on top.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.ButtonType;
      import javafx.scene.control.Dialog;
      import javafx.scene.control.Label;
      import javafx.stage.Modality;
      import javafx.stage.Stage;
      import javafx.stage.Window;

      public class HelloFx extends Application {
          @Override
          public void start(Stage primaryStage) {
              
              Scene scene = new Scene(new Label("Primary Stage"), 640, 480);
              primaryStage.setScene(scene);
              primaryStage.show();
              
              new TestStage(primaryStage, "First Window").show();

              TestStage secondStage = new TestStage(primaryStage, "Second Window");
              secondStage.show();

              openLastWindow(secondStage);
          }
          
          void openLastWindow(Window owner) {
              Dialog dialog = new Dialog();
              dialog.initOwner(owner);
              dialog.setContentText("Hello world!");
              dialog.setTitle("Last Dialog");
              dialog.initModality(Modality.WINDOW_MODAL);
              dialog.getDialogPane().getButtonTypes().add(ButtonType.CLOSE);

              dialog.showAndWait();
          }
      }

      class TestStage extends Stage {
          public TestStage(Window owner, String title) {
              initOwner(owner);
              setTitle(title);
              
              this.setScene(new Scene(new Label("Hello World!"), 400, 400));
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pbansal Pankaj Bansal
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: