import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.text.Text; import javafx.scene.Scene; import javafx.scene.text.Font; import javafx.scene.layout.Pane; import java.time.LocalTime; public class KlokkeFasit extends Application { Text text = new Text(naa()); static Thread traad; private class SekundTeller extends Thread { public void run() { boolean slutt = false; while (!slutt) { try { Thread.sleep(1000); } catch (InterruptedException ie) { slutt = true; } text.setText(naa()); } } } public void start(Stage stage) { text.setY(100); text.setFont(new Font(100)); Pane root = new Pane(text); stage.setScene(new Scene(root)); stage.setTitle("Klokken er"); stage.show(); traad = new SekundTeller(); traad.start(); } private String naa() { LocalTime t = LocalTime.now(); return String.format("%02d:%02d:%02d", t.getHour(), t.getMinute(), t.getSecond()); } public static void main(String[] args) { launch(args); traad.interrupt(); } }