如何在javafx中调用onAction(ActionEvent event)方法

时间:2018-12-10 10:42:58

标签: java events javafx event-handling javafx-8

在initialize()方法中调用onAction(ActionEvent event)方法时,我在javafx中遇到问题。

这是javafx代码:

public class MainViewController implements Initializable {

    @FXML
    private Label lblHeading;

    @Override
    public void initialize(URL url, ResourceBundle rb) {
        btnLoginUserOnAction(null);
    }

    @FXML
    private void btnLoginUserOnAction(ActionEvent event) {
        String getId = ((Button) event.getSource()).getText();
        lblHeading.setText(getId);
    }

}

我如何在btnLoginUserOnAction(ActionEvent event)中称呼initialize(URL url, ResourceBundle rb)。如果我将null传递给ActionEvent参数,那么我将显示execption,因为Event我们null

有帮助吗?

0 个答案:

没有答案