Help with wait statement

Basically I have my main GUI Window opening a secondary form window and then waiting. It will stop waiting when the user submits form data through the secondary window and clicks submit (this calls notify on the main GUI).

The problem is that the secondary window is not displaying; when I call wait right after creating it the whole GUI locks up while waiting to be notified (which won't happen because the secondary window is not loading first). It loads fine if I take out the wait statement right after, but I need it there to acheive the desired functionality. Here is the relevant code.

java.awt.EventQueue.invokeLater(new Runnable(){

publicvoid run(){

new ClassChooserWindow(g, lm, cm);

}

});

synchronized (this){

try{

wait();

}catch(Exception e){

e.printStackTrace();

}

}

I appreciate any ideas you can give me.

[1448 byte] By [Malcolm_Fa] at [2007-10-3 3:28:38]
# 1

There are really only two ways to go:

1) Use a modal dialog

2) Don't do this stuff from the dispatcher thread, create a new thread to do it.

You shouldn't be using wait like this anyway. There should be a flag to test, set when your dialog window closes and you should test it inside the synchronized and before wait()

Message was edited by:

malcolmmc

malcolmmca at 2007-7-14 21:22:15 > top of Java-index,Java Essentials,Java Programming...