JDK-8263801 : [macos] Modal JDialog gets hidden behind parent frame
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8,11,15,16
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: os_x
  • CPU: x86_64
  • Submitted: 2021-03-17
  • Updated: 2021-07-22
  • Resolved: 2021-07-22
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.
Other
tbdResolved
Description
ADDITIONAL SYSTEM INFORMATION :
Mac mini (2018, Inter Core i5, macOS Big Sur 11.1).
Problem reproduce with Java versions 8, 11, 15 and 16 (Oracle JDK, AdoptOpenJDK, Amazon Corretto).

A DESCRIPTION OF THE PROBLEM :
Modal dialog gets hidden behind it's parent frame.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run test code on macOS Big Sur.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Modal dialog remains in from of it's parent frame.
ACTUAL -
Modal dialog gets hidden behind it's parent frame.

---------- BEGIN SOURCE ----------
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;

public class Test {
  public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.getContentPane().setLayout(new FlowLayout());
    JButton button = new JButton("Open modal dialog");
    button.addActionListener(e -> actionOpenDialog(frame));
    frame.getContentPane().add(button);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(600, 450);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }

  private static void actionOpenDialog(JFrame frame) {
    JDialog dialog = new JDialog(/* parent */ frame, /* modal */ true);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setSize(300, 200);
    dialog.setLocationRelativeTo(dialog.getParent());
    dialog.setVisible(true);
  }
}
---------- END SOURCE ----------

FREQUENCY : always



Comments
Additional Information from submitter: =========================== Works as expected on macOS Big Sur 11.2.1 (Mac mini M1 2020). So it is either restricted to Big Sur 11.1, or processor architecture.
22-03-2021