I have a question about event handling in JavaFX. According to the tutorial (and other examples I've come across), event handling is done in JavaFX as follows:
Button addBtn = new Button("Add"); addBtn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { System.out.println("Add Clicked"); } });
But, I wonder if I can “process” the button, click the following path:
Button addBtn = new Button("Add"); addBtn.setOnAction(new addButtonClicked());
where addButtonClicked() is my own class (with its own set of methods and functions), which I defined and wrote to handle actions for clicking a button.
Is there a way to bind custom event handler classes for buttons in JavaFX?
source share