2

My application has several JFrames. One of them might display an application modal dialog using JOptionPane.showConfirmDialog(), for example if the user tries closing the frame with unsaved changes.

The modal dialog blocks input to the other frames, as intended, but it doesn't prevent other windows coming to the front. This might happen if a notification occurs and one of the other frames calls toFront(), for example, or if the user clicks on one of the other windows.

As a result, the modal dialog can get hidden behind other windows and the user is left thinking the application has locked up, unless they hunt around and manage to find the correct window.

This sounds like a bug to me. Java 6 on Mac OS X ensured that a modal dialog always stayed on top but with Java 7 they can end up stuck behind other windows which is very undesirable. Is there any simple way to get the old behaviour back? Preferably without having to change showXXXDialog() to createDialog()/setVisible(true) in hundreds of places!

Rolf
  • 632
  • 1
  • 6
  • 17
  • 1
    See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/a/9554657/418556) – Andrew Thompson May 27 '14 at 03:43
  • See [this answer](http://stackoverflow.com/questions/23467700/jdialog-blocks-parent-window-on-windows/23469809#23469809). Hope it'll help – A Stranger May 27 '14 at 04:26
  • Removing multiple JFrames is not an option. The application is huge (15+ years development), but also a majority of the user base is on Mac where it is common for applications to support multiple top level windows. MDI is completely inappropriate on this platform and the app already makes use of JTabbedPane and floating dialogs to reduce the number of frames. – Rolf May 27 '14 at 08:26

1 Answers1

0

It seems like this was fixed in Java 8. When I tested with Java 8 u45 it was corrected for me on OSX 10.10.3. You could update to Java 8 yourself or package the Java 8 JRE with your application for other users.

AaronJ
  • 1,060
  • 10
  • 24