I have ran into the same problem before, and I am not real sure if there is a fix for it. I first tried to put the query in a
thread, but it still ate so much CPU time that it still didn't paint my wait window. So then I tried using a wait command of some sort or a for loop just as a counter so that it would draw the JFrame and then go to the other process but that didn't seem to work either. Someone else on here I read a while back said it was a
JAVA problem. I hope that someone has a fix for it though. I know this doesn't solve your problem, but I just wanted to add my two cents.
Happy Coding