I want my program to start off using a countdown timer that will be displayed to the user. The only way I can think to do that is to label.setText() and Thread.sleep(). I’ve tried for about 20min trying to get it to work, but can’t seem to crack it. Help?
Share
Use a Swing timer. Basically you create a class that implements
ActionListener, create ajavax.swing.Timer, and theactionPerformedmethod of theActionListenergets called at an interval you specify. In youractionPerformedmethod, check the time, and update the value to be displayed when appropropriate, and callrepaint(). Use an interval of 0.1 second, and your countdown will be smooth and accurate enough.