I am writting some easy program in Java FX. I am begginer in Java. I would like make, You fill textbox (time in minutes) and run it. And than it run timer.schedule that it will every minute refresh label with time. Something like stopwatch. (You set time whitch you want remember time).
I have Controller
public class Controller implements Initializable {
@FXML
public Label label;
@FXML
private TextField timeEnd;
.
.
And method onClick
@FXML
private void handleButtonAction(ActionEvent event) {
Integer timeEndVal = Integer.parseInt(timeEnd.getText());
Date startDate = new Date();
Date endDate = new Date();
endDate.setTime(startDate.getTime() + (timeEndVal * 60000));
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
long currentMinutes = currentTime().getTime() - startDate.getTime();
System.out.println(currentMinutes / 60000 + " / " + timeEndVal + " min");
label.setText(String.valueOf(currentMinutes / 60000 + " / " + timeEndVal + " min"));
}
}, 0, 60000);
But I don't know, how I get label
variable to timer.schedule
.
What I do wrong. Thank for helping.