A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Originally posted by Ryu Eda:
regarding the submit button type thing, i understand but this program is trying to emulate a console type thing [ for example if you think of irc chat rooms, you can type whatever junk... or you can enter something like /join #w/e, ] a submit button, i think, should be basically the same as a JtextField firing an actionevent.
Originally posted by Ryu Eda:
Anyway, i tried reading all that stuff on the MVC and eventthreads but i couldnt really figure out a solution to my problem from that, however i did figure out what my problem was anyway from a threading article.
For anyone who faces this problem, the answer seems to be using
try { Thread.sleep(25); }
catch (InterruptedException e) { }
using some sort of small value for sleep so that instead of trying to loop as many times as it can at every moment, thus eating some crazy cpu power, it only loops once every 25 milliseconds, which apparently is really rarely for a computer since it dropped cpu usage from 80% to 3%, and it doesnt really seem to have any noticeable effect on GUI responsiveness
thanks for the help guys
[ July 11, 2006: Message edited by: Ryu Eda ]
For the user input, you need to get comfortable with giving control to the UI. While you're waiting for input, NO application code runs in any thread. It all just sits there waiting for something to happen. When the user hits a keystroke or a submit button the Swing component calls a listener and the listener runs some interesting response.
If you need to know when the other thread reaches a certain point without finishing it may be a simple callback or something with Object.wait() and Object.notify().
Assuming that the scrollbar won't work and you really do want paged text in an output window why not add a listener to the output window? Your app would just sit there doing nothing until the user pressed a button to continue or cancel. The button could be a GUI button that they clicked with the mouse or it could be a keystroke somewhere. Your listener will know what the keystroke was and could do various things (continue or cancel) based on the value of the keystroke.
Your app would just sit there doing nothing until the user pressed a button to continue or cancel
'm not sure that I understand the need for different threads. Especially if you're just going to do a join or wait. In those cases you're defeating the parallelism that the thread model gives you. The join and wait methods have their place with thread but they are used after the thread has done it's independant, parallel work.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi