disposing modal Dialog loses modality occasionally

yay, a new bug - I got a knack for finding awt/swing bugs :stuck_out_tongue:

Can somebody else confirm this is a bug? (and does it only affect windoze?)

Just close the dialog a few times(2-3 times on my machine), it will lose its modality (show() will stop blocking).

This is when using WinXP and Java 1.4.x or 1.5.


import javax.swing.*;
public class DialogBug
{
   public static void main(String [] args)
   {
      JDialog fred = new JDialog((JFrame)null, true);
      fred.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
      
      int i = 0;
      while(true)
      {
         System.out.println(i++);
         fred.show();
      }
   }
}

I guess the problem is caused by show() executing in my Thread, and dispose() is executing in the EventDispatchThread.
However, should this be considered a bug in my code?
If so, 99% of awt code out there is potencially buggy!
(Who realy bothers executing show() on the event dispatch Thread :S)

:edit:

Ofcourse, because show() blocks for Dialogs, it HAS to be called from a Thread other than the EventDispatchThread.

So, there is NO other way of doing this (apart from hiding the frame, and then disposing of it once show() returns)

I think this realy needs fixing, as its a fundamental of Dialogs.