Question: Rewrite Programming Exercise using a thread to control the clock animation. Modify Listing, ClockPane.java, to add the animation into this class and add two methods?start()?and?stop()?to
Rewrite Programming Exercise using a thread to control the clock animation.
Modify Listing, ClockPane.java, to add the animation into this class and add two methods?start()?and?stop()?to start and stop the clock. Write a program that lets the user control the clock with the?Start?and?Stop?buttons, as shown in Figure.

(a) Exercise allows the user to start and stop a clock.
Listing



|Exercise15_32 -D|| 12 3 Start Stop (a) 1 import java.util.Calendar; 2 import java.util.GregorianCalendar; 3 import javafx.scene.layout.Pane; 4 import javafx.scene.paint.Color; 5 import javafx.scene.shape.Circle; 6 import javafx.scene.shape.Line; 7 import javafx.scene.text.Text; 8 9 public class ClockPane extends Pane { private int hour; private int minute; private int second; 10 11 12 13 // Clock pane's width and height private double w = 250, h = 250; 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 /** Construct a default clock wi th the current time*/ public ClockPane() { setCurrentTime(); /** Construct a clock with specified hour, minute, and second */ public ClockPane(int hour, int minute, int second) { this.hour - hour; this.minute - minute; this.second = second; paintClock (); /** Return hour */ public int getHour() { return hour; 31 32 33 34 35 36 37 /** Set a new hour */ public void setHour(int hour) { this.hour = hour; paintClock (); 38 39 40 { 41 /** Return minute */ public int getMinute() { return minute; 42 43 44 45
Step by Step Solution
3.50 Rating (160 Votes )
There are 3 Steps involved in it
Program plan Create class Exercise3007 which inherits from Application class In class Exercise3007 Override the start method of Application class Create a class ClockPane which inherits from Pane In m... View full answer
Get step-by-step solutions from verified subject matter experts
