JDK-8190230 : [macosx] Order of overlapping of modal dialogs is wrong
  • Type: Bug
  • Component: client-libs
  • Affected Version: 8u112,9,10
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • CPU: generic
  • Submitted: 2017-10-26
  • Updated: 2018-12-11
  • Resolved: 2017-11-02
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
10 b31Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
On Mac OS modal dialogs overlapping order is wrong.

Below a test that demonstrates the wrong behavior is provided (a modified test taken from https://stackoverflow.com/questions/46922555/correct-parent-for-modal-dialog-in-swing).
Run the test and create 4 consequently modal dialogs using the button. Their appeared overlapping order is 
4 - 1 - 2 - 3
but the expected order is
4 - 3 - 2 - 1

======================
import javax.swing.*;
import java.awt.*;

public class Main extends JFrame {
    MyPanel panel;
    private static int shift = 0;

    public Main() {
        setTitle("This is a frame");
        setSize(300, 200);
        panel = new MyPanel(this);
        add(panel);

        setLocationRelativeTo(null);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

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

    private static class MyPanel extends JPanel {

        int dialogCounter = 1;
        final JFrame theParent;

        public MyPanel(JFrame parent) {
            super();
            theParent = parent;
            setPreferredSize(new Dimension(300, 200));
            JButton button = new JButton("Press the button");
            button.addActionListener(e -> showDialog(theParent));

            add(button);
        }

        private void showDialog(Frame parent) {
            JDialog dialog = new JDialog(parent, "This is dialog " + dialogCounter, true);
            shift += 40;
            dialog.setLocation(parent.getX() + shift, parent.getY() + shift);
            setupDialog(dialog);
        }

        private void setupDialog(JDialog dialog) {
            JPanel dialogPanel = new JPanel();
            dialogPanel.setPreferredSize(new Dimension(300, 200));
            dialogPanel.add(new JLabel("Current dialog count: " + dialogCounter++));
            JButton button = new JButton("Open a new modal dialog");
            button.addActionListener(e -> showDialog(theParent));
            dialogPanel.add(button);
            dialog.add(dialogPanel);
            dialog.pack();
            dialog.setVisible(true);
        }
    }
}






Comments
This is regression of JDK-8169589
26-10-2017