This article will provide an instance of creating one type of stopwatch with Java Applet, AWT and Thread.
We shall be using all these library to make a working model of a stopwatch. The GUI shall have 3 buttons for interaction, namely, start (to start the time), reset (to reset the time to default value) and stop (to stop the timer).
With the help of actionListener in Java we can learn which button is pressed when.
- When the start button is pressed, we start the timer. While the reset or the stop button isn’t pressed we shall keep the timer running i.e. we shall change the value of the timer (hh:mm:ss:ms) every 1 millisecond and update the screen.
- When reset button is pressed, we shall stop the timer and set it to is default value (00:00:00:000).
- When the stop button is pressed, we stop the timer with the value as it is.
Below is the implementation of Digital Stopwatch
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- Java Applet | How to display a Digital Clock
- How to create a Stopwatch App using Android Studio
- Difference between a Java Application and a Java Applet
- Java Applet Basics
- Draw a Polygon in Java Applet
- Java Code for Moving Text | Applet | Thread
- Draw a ellipse and a rectangle in Java Applet
- Java Applet | Implementing Flood Fill algorithm
- Draw a Chessboard in Java Applet
- Draw an Olympic Symbol in Java Applet
- Draw a Smiley in Java Applet
- Java Applet | Draw a line using drawLine() method
- Java Applet | How to display an Analog Clock
- Android | How to display Analog clock and Digital clock
- Java.util.BitSet class methods in Java with Examples | Set 2
- Java.Lang.Float class in Java
- Java.io.BufferedInputStream class in Java
- Java.io.ObjectInputStream Class in Java | Set 1
- Java.util.BitSet class in Java with Examples | Set 1
- Java.io.File Class in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.