I am currently using JavaFX and I want to reuse a method from another class. I have the method in a class called about and I want to reuse the method in a class called contact. Its a simple method, all it does is changes scene after the button is clicked. Code is below:
public void logoutButtonClick (ActionEvent actionEvent) throws IOException {
Parent root = FXMLLoader.load(getClass().getResource("FirstPage.fxml"));
Stage window = (Stage) logoutButton.getScene().getWindow();
window.setScene(new Scene(root, 800,500));
}
public void logoutButtonClick(ActionEvent actionEvent) throws IOException {
aboutController aboutController = new aboutController();
aboutController.logoutButtonClick();
}
At the moment I am getting an error:
java: method logoutButtonClick in class com.example.demo2.aboutController cannot be applied to given types;
required: javafx.event.ActionEvent
found: no arguments
reason: actual and formal argument lists differ in length
It is expecting something in the brackets but I am unsure what it is. Any help would be great. Thanks
Some more code of the classes:
public class contactController extends aboutController{
@FXML
public Button logoutButton;
public void logoutButtonClick(ActionEvent actionEvent) throws IOException {
aboutController aboutController = new aboutController();
aboutController.logoutButtonClick(actionEvent);
}
public class aboutController {
@FXML
public Button logoutButton;
public void logoutButtonClick (ActionEvent actionEvent) throws IOException {
Parent root = FXMLLoader.load(getClass().getResource("FirstPage.fxml"));
Stage window = (Stage) logoutButton.getScene().getWindow();
window.setScene(new Scene(root, 800,500));
}