Java Applet | How to display an Analog Clock
In this article, we shall be animating the applet window to show an Analog Clock with a 1-second delay. The idea is to display the system time of every instance.
Each hand of the clock will be animating with 1-second delay keeping one end at the centre. The position of the other end can be derived by the system time. The angle formed by a hand of the clock in every second will be different throughout its journey. This is why various instances make a different angle to the horizontal line.
How to run:
1. Save the file as analogClock.java and run the following commands. 2. javac analogClock.java 3. appletviewer analogClock.java
Below is the implementation of the above approach: