Steps to install application:
- In command line got to clock.jar file
- run: java -jar clock.jar
- Working app
- setStyle();
currentTime.setStyle("-fx-font-size:20px; -fx-font-weight: bold; -fx-text-fill:rgb(104, 137, 128, 0.99); -fx-padding: 10 0 0 0;");
- To set the style of the currentTime label, I use setStyle(). This allows me to use css for styling the application.
- Timer
Timer timer = new Timer();
TimerTask task = new TimerTask() {
public void run() {
Platform.runLater(new Runnable() {
@Override
public void run() {
update();
renderClockCircle(pane);
renderHours(pane);
renderClockArms(pane);
}
});
}
};
timer.scheduleAtFixedRate(task, 0, 1000l);- This portion of the code takes care of refreshing the clock every second. It creates a timer and task. The Platform.runLater(new Runnable()) makes sure that the run() code gets executed. the timer.scheduleAtFixedRate(task, 0, 1000l); calls the task with a delay of 0, every 1000 milliseconds.
- Carlos Toledo