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
- Java Applet | How to display a Digital Clock
- Java Applet Basics
- Draw a Chessboard in Java Applet
- Draw a Polygon in Java Applet
- Draw a Smiley in Java Applet
- Java Applet | How to display an Analog Clock
- Draw a ellipse and a rectangle in Java Applet
- Draw an Olympic Symbol in Java Applet
- Java Applet | Draw a line using drawLine() method
- Java Applet | Implementing Flood Fill algorithm
- Java Code for Moving Text | Applet | Thread
- Android | How to display Analog clock and Digital clock
- Java.util.LinkedList.poll(), pollFirst(), pollLast() with examples in Java
- Java.util.concurrent.Phaser class in Java with Examples
- Java.util.concurrent.RecursiveTask class in Java with Examples
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.