I'm taking the
SCJD exam, but I've decided to post this question here instead because I think it deals specifically with Swing/JFC/AWT issues. The situation is as follows:
I have a JDialog that appears over my main JFrame. The JDialog has two buttons: a "Wait Now" and a "Try Again Later." When the user selects the "Try Again Later" button the JDialog is closed and the JFrame is again the active window, and its contents appear just as they did before the JDialog was popped-up. This works according to my expectations without any problem.
If the user selects the "Wait Now" button the JDialog is closed, I change the cursor to a busy cursor, and then I make a call to wait() (hence the name, Wait Now). I would expect the JDialog to disappear (it does), I would expect to see a busy cursor (I do), and I would expect to see the original contents of the JFrame (I DON'T), and then I would expect the window to remain frozen until my
thread is notified (it does). Instead what I see is the original contents of the JFrame with a greyed-out area where the JDialog was. In other words, the JFrame doesn't get repainted. Furthermore, if I iconify the JFrame in this state it comes back completely greyed out.
So my question is this: why do I have that greyed-out area where the JDialog was displayed and how can I get rid of it. I want to simply see the original contents of the JFrame while I wait for my thread to become active again.
I have tried calling repaint() on the JFrame after closing the JDialog but this doesn't seem to fix the problem.
I'm guessing that because I make my thread wait() I'm somehow interfering with the repaint() but I confess I don't understand the mechanism enough to solve the problem.
Can anyone here help?