Exercise 3: Draw a Real-Time Clock with Graphics2D
Write a Java program to simulate a real-time clock that matches the output below. The clock should have three hands for hours, minutes, and seconds. The application frame and the clock should have a fixed size (no resizing will be required).
Clock
12
The following code fragment shows Graphics2D code for rotating the second's hand, using geometric transform. In this example, seconds is the number of seconds in the current time, while X and Y are the screen coordinates for the center of rotation.
g2.rotate(Math.toRadians(seconds * 6.0), X, Y);
drawSecondHand();
g2.rotate(Math.toRadians(seconds * 6.0), X, Y);
You will need to implement the drawSecondHand() method to draw the second's hand at a fixed location, then create similarly two methods to draw the hands for hour and minutes.