You could use the following for the countdown
class ButtonCountdown implements ActionListener {
int count=0;
JButton button = null;
public ButtonCountdown(final JButton button, int count){
this.count = count;
this.button = button;
}
public void actionPerformed(ActionEvent e) {
if (count>0){
button.setText(String.valueOf(--count));
} else {
button.setText("Done!");
}
}
}
and then start it like so after you have the UI all set up
Timer koTimer = new Timer(1000, new ButtonCountdown(ko, 5));
koTimer.start();
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Offline 6,761 posts
since May 2007