button.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent e) {
label.setText("Accepted");
}
});
In the above code, we determine what happens when we press the button. This is all well and good, but I want to create a new ActionListener and then add it to my button. Usually in JButton I can simply add an ActionListener as follows:
button.addActionListener(someControllerClass.createButtonListener());
In the code above, createButtonListener () returns an ActionListener.
My question is: what is the equivalent of JButton addActionListener?
source
share