well, in my program, i want to add a clock to show player left time, and there is a button and a label, after user click the btn, label will show a sentence, after a while, e.g. 1 second, the sentence will be removed and the btn is actived again, so that user can click on it and show next sencence, and things go on.
currently, i use two threads, one is timer, another is textThread, in my run() method, if Thread.currentThread()==timer, i decrease remainTime by 1 and show it, if Thread.currentThread()==textThread, i display the text on the label and then sleep 1 second, but it has no reaction at all. am i on the right way? is there any alternative method?
perhaps you could solve your problem like this: when the button is pressed, display your sentence, deactivate the button and start a java.util.Timer. The run()-method of your timer removes the sentence from the label and reactivates the button. Some code snippets: