I want to build a “Work in progress…”-JFrame before calling a method that might take some time but the JFrame won’t be fully rendered before the method is executed.
I know I’m not the first with that problem, I always find solutions involving threads (do the long working method in a thread and so on). But I don’t want to for particular reasons (and it might be that I’m not even able to unless I want the system to go boom).
So, is there a possibility to tell Swing to first render a window and then do the rest? Something like get rendering the window to be the first in the excecute-queue?
You might be able to do it by displaying the JFrame and then calling
But it’s really a bad idea. The GUI will be frozen for the whole duration of the method.
The right way to do it is, indeed, to use a background thread. But Swing has all you need to make it painless. Simply use a
SwingWorker. Its API doc is well-written and has examples. Try doing it, and if you can’t, Ask another question and show the code you have tried so that someone helps you.