JDK-8190522 : [macos] Wrong dialog on top with multiple modal dialogs (regression)
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8u131,9,10
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: os_x
  • CPU: x86
  • Submitted: 2017-10-25
  • Updated: 2018-04-04
  • Resolved: 2017-11-15
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_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Mac OS Sierra 10.12.6
uname -a output:
Darwin Jessicas-MacBook-Pro.local 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64

A DESCRIPTION OF THE PROBLEM :
When a modal dialog (A) with parent Frame F creates a new modal dialog (B) with the same parent F, dialog (A) appears on top of dialog (B), even though (B) has focus. Clicking on either dialog corrects focus.

This bug is also present in 8u162:
java version "1.8.0_162-ea"
Java(TM) SE Runtime Environment (build 1.8.0_162-ea-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b01, mixed mode)

Also in 9.0.1:
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)


REGRESSION.  Last worked in version 8u141

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


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the attached source code
2. Launch. Click the "Press the button" button in the application window.
3. A new dialog will open. Click the "Open a new modal dialog" button. A new dialog opens, but it's beneath the previous dialog (dialogs are numbered sequentially so you can easily see which opened first).
4. Click any of the open windows and the last dialog opened will appear on top

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The dialog with focus should appear on top. 
ACTUAL -
The dialog in focus is beneath another dialog.

REPRODUCIBILITY :
This bug can be reproduced always.

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

public class Main extends JFrame {
    MyPanel panel;

    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, false);
            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.setModal(true);
            dialog.setVisible(true);
        }
    }
}
---------- END SOURCE ----------


Comments
Closing this as duplicate of JDK-8190230
15-11-2017

This bug is already resolved in another bug JDK-8190230 and hence no more reproducible and can be closed.
07-11-2017

Already resolved and no more reproducible. Hence this bug can be closed.
07-11-2017

Non reproducible hence closed. It is also a duplicate issue and resolved under bug https://bugs.openjdk.java.net/browse/JDK-8190230.
07-11-2017

Non reproducible on the latest of the JDK 10 sources. The latest modal dialog is appearing above the earlier dialog and even the destruction of dialogs appear to be in order.
06-11-2017

Probably duplicate of JDK-8190230
03-11-2017

JDK 8u152 MAC OS X 10.12.6 Reported with 8u152, a modal dialog (A) with parent Frame F creates a new modal dialog (B) with the same parent F, dialog (A) appears on top of dialog (B), even though (B) has focus. Clicking on either dialog corrects focus. Verified this with reported versions and could confirm the issue as reported. Results: ================= 8u121 - OK 8u131 - FAIL 8u152 - FAIL 8u162 b03 - FAIL 9: FAIL 9.0.1 - FAIL 10 - FAIL This seems a regression introduced with JDK 8u131 and affects JDK 9 as well as 10.
02-11-2017