Samarstan Applet Applets

Grandfather Clock Applet

  • This is the Applet :

  • GrandClock.java - This is the Source Code

  • Notes :
    • A bug still exists in this applet.
    • The this in new Thread(this) indicates that the applet provides the body of the thread; by implementing java.lang Runnable interface, which requires the applet to provide a run method that forms the body of the thread.
    • Thread.currentThread remembers which thread we are in.
    • The java.lang.Date of Java 1 methods like getSeconds() are deprecated due to internationalisation they are replaced by java.util.Calendar class in Java 2.
    • Calendar is an abstract class and so canot be instantiated
    • Math.sin() take only radians as input
    • x increases as y decreases because (0,0) is at the upper left-hand corner, so dy must be subtracted from y
    • The center is (50,50) whilst radius is also 50.
    • sleep should be in while loop as otherwise repainting is too fast
    • Radius of hour hand is 30, minute hand is 40, second hand is 30

Samarstan Applet Applets