I am a student, I am creating a clock for an application, I added a Label in scene builder assigned the clock to it and added the following java code:
public void initialize() throws FileNotFoundException, InterruptedException {
var now = LocalTime.now();
DateTimeFormatter dft =DateTimeFormatter.ofPattern("HH:mm:ss");
labelclock.setText(LocalTime.now().format(dft));
I want to make the clock tick and tried in many ways but it didn't work.
I also tried creating the clock in another way and got the same result.
public void setTime() {
while (true) {
time = timeFormat.format(calendar.getInstance().getTime());
labelclock.setText(time);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}