Thanks to visit codestin.com
Credit goes to github.com

Skip to content

kqarlos/clock-javafx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clock Java-FX

Getting Started

Steps to install application:

  1. In command line got to clock.jar file
  2. run: java -jar clock.jar

Site Pictures

  • Working app

`` ` Site

Code Snippets

  1. 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.
  1. 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.

Built With

Author

  • Carlos Toledo

Links

About

Displays a live clock usign JAVAFX

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages