I want to add a method to a button which is defined in my Controller class
in the console is only an error which tells me that it couldn't find the method
here is the code
sample.fxml
and the Controller.java
package sample;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import java.awt.event.ActionEvent;
import java.net.URL;
import java.util.ResourceBundle;
public class Controller implements Initializable
{
@Override
public void initialize(URL url, ResourceBundle resourceBundle)
{
}
@FXML
private void test(ActionEvent event)
{
System.out.println("lollolol");
}
}
解决方案
Replace:
import java.awt.event.ActionEvent;
with:
import javafx.event.ActionEvent;