将此代码放入我的控制器类时出错:"没有为关键帧找到合适的构造函数"

时间:2017-12-26 15:11:07

标签: javafx

在下面提到的部分中出现错误:

import com.jfoenix.controls.JFXButton;
import static com.sun.org.apache.xalan.internal.lib.ExsltDatetime.time;
import java.awt.event.MouseEvent;
import java.net.URL;
import java.time.Duration;
import java.util.Calendar;
import java.util.ResourceBundle;
import javafx.animation.Animation;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.control.Label;  

    public void initialize(URL url, ResourceBundle rb) {
    Timeline clock = new Timeline(new KeyFrame(Duration.ZERO, e -> {  /*getting error here*/          
    Calendar cal = Calendar.getInstance();
    second = cal.get(Calendar.SECOND);
    minute = cal.get(Calendar.MINUTE);
    hour = cal.get(Calendar.HOUR);
    time.setText(hour + ":" + (minute) + ":" + second);
    }),
    new KeyFrame(Duration.seconds(1));/*getting error here for seconds(1)*/
    );
    clock.setCycleCount(Animation.INDEFINITE);
    clock.play();
    }

0 个答案:

没有答案