import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.VBox; import javafx.scene.text.Font; import javafx.scene.text.Text; import java.time.LocalTime; public class Klokke extends Application { Text hilsen = new Text(naa()); class SekundTeller extends Thread { boolean slutt = false; public void run() { while (! slutt) { try { sleep(1000); } catch (InterruptedException e) { slutt = true; } hilsen.setText(naa()); } } } private static String naa() { LocalTime t = LocalTime.now(); return String.format("%02d:%02d:%02d", t.getHour(), t.getMinute(), t.getSecond()); } @Override public void start(Stage teater) { hilsen.setFont(new Font(100)); VBox box = new VBox(); box.getChildren().add(hilsen); Scene scene = new Scene(box); teater.setScene(scene); teater.show(); new SekundTeller().start(); } public static void main(String[] args) { Application.launch(args); System.exit(1); } }