Question: Analog Clock Using JavaFX, make an analog clockface that shows an hour hand, a minute hand, and a second hand. The hands should update every

Analog Clock

Using JavaFX, make an analog clockface that shows an hour hand, a minute hand, and a second hand. The hands should update every second. The second hand can be implemented as a dot or as a thin hand.

It is not necessary to place numbers or tick markers on the clock, but that would be added niceness.

Also, the UI should include a Text area that shows the current time as text, such as "Sunday, August 12, 2018 1:11pm".

You will have to use a timer that will go off once a second to run a task that will get the system time, and then interpret that time on the face of the JavaFX clock.

Here is a method that will make this project easier to implement. I've handled all the trigonometry. Note there are 2*Analog Clock Using JavaFX, make an analog clockface that shows an hour radians in a circle. You may also wish to use the Math.toRadians(double degrees) method to convert degrees to radians.

 /** * Create a JavaFX Line, given a start point, a length and an angle. * @param angle the angle in radians starting counterclockwise from horizontal. */ private Line makeLine(Point2D start, double length, double angle) { double incrementX = length*Math.cos(angle); double incrementY = -length*Math.sin(angle); // negative because y values inverted Point2D end = start.add(new Point2D(incrementX, incrementY)); Line l = new Line(start.getX(), start.getY(), end.getX(), end.getY()); return l; } 

Further hint: the mapping from hour to angle, or from minute to angle, or from seconds to angle is linear. If you cannot figure them out, email me and I will provide them. Note that 3 o'clock maps to an angle of 0. 12 o'clock maps to an angle of pi/2 (for the hour hand, that is).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!