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

[macosx] A second modal dialog appears behind a previous modal dialog

    Details

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_131"
      Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
      Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      mac OSX 10.10.5, macOSX 10.11, macOS Sierra, v. 10.12.4

      Darwin Mac-mini-de-Oscar.local 16.5.0 Darwin Kernel Version 16.5.0: Fri Mar 3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64


      A DESCRIPTION OF THE PROBLEM :
      If one application has several modal dialogs with the application frame as parent, and one of them shows another modal dialog, the last modal dialog appears behind the previous modal dialog.

      REGRESSION. Last worked in version 8u111

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.8.0_111"
      Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Execute the Test class.

      Although in this case the dialog 1 could be the parent of the dialog 2, in complex applications this is not possible. For example, when a database search dialog could be used in several locations, the parent must be the application frame.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The dialog 2 must appear above the dialog 1.
      ACTUAL -
      The dialog 2 appears behind the dialog 1.
      Also, sometimes the two modal dialogs apperas above of all desktop applications.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import javax.swing.*;

      public class Test extends JFrame
      {
      private JDialog dlg1, dlg2;

      public Test()
      {
          super("Frame");
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          setBounds(100, 100, 300, 300);
          dlg1 = new Dialog1(this);
          dlg2 = new JDialog(this, "Dialog 2", true);
          JButton button = new JButton("Show Dialog 1");

          button.addActionListener(e ->
          {
              dlg1.setBounds(300, 150, 300, 200);
              dlg1.setVisible(true);
          });

          setLayout(new FlowLayout());
          add(button);
      }

      private class Dialog1 extends JDialog
      {
          private Dialog1(JFrame owner)
          {
              super(owner, "Dialog 1", true);
              JButton button = new JButton("Show Dialog 2");

              button.addActionListener(e ->
              {
                  dlg2.setBounds(500, 225, 250, 100);
                  dlg2.setVisible(true);
              });

              setLayout(new FlowLayout());
              add(button);
          }
      }

      public static void main(String[] args)
      {
          EventQueue.invokeLater(() -> new Test().setVisible(true));
      }

      } // Test

      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ssadetsky Semyon Sadetsky (Inactive)
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: