views:

563

answers:

1

Stumped by this, but maybe, just maybe, someone has had this problem before and can point me in the right direction...

I have a JDialog for displaying the progress of a long-running task, which I have expressly created as modal with a defined owner:

  progressDialog = new JDialog( ((Dialog)windowParent), true );
  ...
  progressDialog.setVisible( true );

Later on, once the task is complete, I close the dialog again:

protected void done() {
  SwingUtilities.invokeLater( new Runnable() {
     public void run() {
        progressDialog.setVisible( false );
     }
  } );
}

Under very rare circumstances, the dialog a) does not close, and b) is not truly modal, i.e. the user is able to interact with the window behind the (theoretical) dialog. Any ideas what might be causing this? Unfortunately it happens very rarely and until now, only on Linux systems. Could this be a Swing bug or am I possibly doing something wrong?

+1  A: 

Even though I cannot provide a definitive solution to your problem, I can tell you that I have seen all sorts of strange behavior with modal dialogs on Linux - many of them depending on the Window manager in place.

For our point of sale system we ended up using the very minimalistic "flwm" window manager, because it provided the most reliable and desired properties. Would not recommend it for a modern Linux desktop however.

As for modality itself: If you can use Java 6 you might want to have a look into the JDK6 modality changes and enhancements: Sun Blog and the accompanying Javadoc for the Dialog.ModalExclusionType

Daniel Schneller