This has been eating me in and out. I will give the code here you can try it out. Sorry it might be a little long/boring.
I first draw a GUI with a button. This is done by 'GUIDrawer'. I start it as a thread so that EDT will not be blocked. And when you click the 'TEST' button, I want to pop up a frome with YES and NO, and according to user click, the string 'password' will be changed.
The problem is, I want to check the value of 'password' 'after' the user had clicked the button. So I have put in wait()/notify() statements (Thanks to Norm).
But the problem is, no matter what I do or how many threads I start, I cannot get the YES and NO buttons on the passwordFrame. It gives me the frame but not the buttons. If I take off the wait() statement I get the buttons. I'm a litle baffled as to why it gives me the frame but I do not getthe buttons? GUITester is the class associated with the TEST button. Which calls the GetPassword thread and wait(). If you comment the monitor.wait() statement in the GUITester class you can see that the passwordFrame gives the buttons. Otherwise no buttons (only frame).
Any help will be greatly appreciated. Thank you.
[ August 02, 2008: Message edited by: Maduranga Liyanage ]
[ August 02, 2008: Message edited by: Maduranga Liyanage ] [ August 02, 2008: Message edited by: Maduranga Liyanage ]
Here's a working version of your code. One problem was doing things on the EDT in the Test button listener. Another was having more than one object: monitor. I forget the others I found.
Joined: May 25, 2005
Originally posted by Ulf Dittmer: Well, if you didn't use threads, there would be no need to call notify() or wait() or any of the other thread-related methods. So I don't see what could block.
The usual way to trigger an action would be to add an action listener to whatever button the user has to click after he has entered the password.
Thanks Ulf. I'll see if I can work with that. I have put an actionlistener to the button the user if clicking after the password. The problem is the button isnt showing up in the frame when I have wait(). But still dosnt understand why the GUI update is blocking by when I have a wait(). [ August 02, 2008: Message edited by: Maduranga Liyanage ]