Right now I'm using Eclipse Luna, JavaFX and SceneBuilder. I have ~40 buttons, and I'd like to use a generic "buttonPressed" action method that every button can use. Something like this:
public void buttonPressed(ActionEvent event, Button b) {
b.setText("Pressed");
}
When I change the On Action panel in SceneBuilder however, I get the following Exception when I try to run my program:
javafx.fxml.LoadException: Error resolving onAction='#buttonPressed', either the event handler is not in the Namespace or there is an error in the script.
Is there a step I missed? Or does anyone know of an alternate way to use one method to control the on-click behavior of multiple buttons?
Any help appreciated!
Button bin as a parameter. Removing it, and specifying a button inside the method remedies the Exception ( but not the problem at hand, as the method can now only be used by one button ). Is there perhaps a different way of locating which button is being pressed and then passing that to the method?