Search code examples
javauser-interfaceswingjdialogmodeless

Modeless JDialog not showing contents


(Java SE 6) I'm trying to create a pop-up dialog that displays a "please wait" message while my program does some time-intensive work. To do this, I've chosen to use a modeless JDialog, so that the program continues to run and does work while the JDialog is visible (if you use a modal one, the program will halt until the dialog is closed by the user).

The problem is that when you use a modeless dialog in this fashion the JDialog with a title appears, but the contents don't (I'm guessing they don't get painted for some reason). I've tried calling repaint etc but nothing seems to work.

Now, according to a bunch of people on the interwebs this is a genuine bug with Swing, and the only answers I've found are to not do things this way and find some other means of notifying the user to wait. I'm curious if anyone here has had this issue before and has figured out a work-around.

Thanks!


Solution

  • As an alternative, consider using SwingWorker and showing interim progress, as suggested in this example.