Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
1. Create an inner event
class class MyEvent< T > implements EventHandler {
public void handle(Event arg0) {
Call Method();
}}
2. Call the setOnAction method for the button and pass it an object of the event class as a parameter.
button.setOnAction(new MyEvent< ActionEvent >());
Or if you only need it once, you can use the anonymous button class
. setOnAction(new EventHandler< ActionEvent >() {
public void handle( ActionEvent e ) {
Method Call();
}
});
If Java 8, you can use lambda expressions:
button.setOnAction(arg0 -> YourMethod());
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question