All GUI events are handled on one
thread. If you wait() in a button press handler, then the GUI can't respond to any more button presses. Event handlers should always return ASAP, and they can never do anything that would involve waiting for more events. Therefore it's obvious why anything you've tried so far would be doomed to fail.
I don't know what your code does exactly, but I'll imagine that when you press one button, it does a long calculation, and when that calculation completes, it enables a button, and then the user has to press that button before the results are presented. The trick, then, is that you want to do the long calculation, the second-button-enabling, and the wait() in a new thread that you spawn yourself. You can do the notify() from the regular event handling thread.
Pseudocode (real code would imply I had to dot all the i's
Make sense? displayResults() should use SwingUtilities.invokeLater() to do any GUI updates (technically I believe I should have used it to call setEnabled(true) although you can generally get away without it.)
[ August 07, 2003: Message edited by: Ernest Friedman-Hill ]