JDK-8179335 : [macosx] A second modal dialog appears behind a previous modal dialog
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8u111,9
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: os_x
  • CPU: x86
  • Submitted: 2017-04-19
  • Updated: 2017-10-09
  • Resolved: 2017-10-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10
10Resolved
Related Reports
Duplicate :  
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 ----------


Comments
The same comments as in JDK-8182638 is applicable for this bug.
22-06-2017

Also, the provided test case includes a scenario where the owner of the dialogs are one and ordering is expected in the manner of calling window. The entire logic of dialog stacking is violated in test case. the second dialog as it is called from first dialog, the first dialog should be made the owner of that dialog. There is error in test case itself.
31-05-2017

This is limitation for Mac OS X Natively, there are 3 window levels. 0,1,2 As far as it looks, with these limitations case 2 is an acceptable working mode as the focus is still on the active modal window. As window levels are not dynamic as in Windows, looks like there is no clean fix for this issue. Also, tapping on any window will bring the correct dialog to foreground.
31-05-2017

Its a regression in Mac OS, works fine in windows. Issue is reproducible in mac OS - later versions of JDK 8 and then in JDK 9, . Test case failing with 2 different types of cases: case 1: 1. Dialog 1 opens above main window 2. Dialog 2 opens above dialog 1 but now dialog 1 appears behind main window Case 2: 1. Dialog 1 opens above main window 2. Dialog 2 opens behind dialog 1 macOS Sierra 10.12.3 ------------------------------ 8u111 : Pass 8u112 : Fail (case 1) 8u121 : Fail (case 1) 8u131 : Fail (case 2) 8u152 : Fail (case 2) 9ea166 : Fail (case 2)
26-04-2017