07:31Java stopwatch ⏱️
From the creator
java stopwatch program #java #stopwatch #program // *************************************************** public class Main { public static void main(String[] args) { Stopwatch stopwatch = new Stopwatch(); } } // *************************************************** import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Stopwatch implements ActionListener{ JFrame frame = new JFrame(); JButton startButton = new JButton("START"); JButton resetButton = new JButton("RESET"); JLabel timeLabel = new JLabel(); int elapsedTime = 0; int seconds =0; int minutes =0; int hours =0; boolean started = false; String seconds_string = String.format("%02d", seconds); String minutes_string = String.format("%02d", minutes); String hours_string = String.format("%02d", hours); Timer timer = new Timer(1000, new ActionListener() { public void actionPerformed(ActionEvent e) { elapsedTime=elapsedTime+1000; hours = (elapsedTime/3600000); minutes = (elapsedTime/60000) % 60; seconds = (elapsedTime/1000) % 60; seconds_string = String.format("%02d", seconds); minutes_string = String.format("%02d", minutes); hours_string = String.format("%02d", hours); timeLabel.setText(hours_string+":"+minutes_string+":"+seconds_string); } }); Stopwatch(){ timeLabel.setText(hours_string+":"+minutes_string+":"+seconds_string); timeLabel.setBounds(100,100,200,100); timeLabel.setFont(new Font("Verdana",Font.PLAIN,35)); t
Published 2020-06-05 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.





