Java Stopwatch that updates the GUI every second?
问题 I'm a Java beginner and I'm trying to build a simple stopwatch program that displays the time on a swing GUI. Making the stopwatch is easy, however I cannot find a way to make the GUI update every second and display the current time on the stopwatch. How can I do this? 回答1: Something along these lines should do it: import java.awt.EventQueue; import java.util.Timer; import java.util.TimerTask; import javax.swing.JFrame; import javax.swing.JLabel; /** @see https://stackoverflow.com/a/11058263