I want to create a JDialog in another thread (will show time),
while in the main thread, a function will run..
when I create the dialog, it is shown, but it is “stuck”…and I can’t see
its components…
Only when the function in the main thread finish – The dialog is shown correctly..
How can I fix it?
If you’re running a large task on the Swing EDT then it will block UI elements from being repainted, since that’s the thread that all Swing painting happens on.
The only sensible way around this is to run your large task on a separate thread. Look into the
SwingWorkerclass: http://docs.oracle.com/javase/6/docs/api/javax/swing/SwingWorker.html