Reputation: 1813
I am creating a project using javafx. I am using netbeans IDE. I had created many classes. When a button is pressed, a function from other class has to be worked. How to make it working ?
Upvotes: 3
Views: 14444
Reputation: 328568
With Java 8:
button.setOnAction(e -> anInstanceOfYourOtherClass.yourMethod());
Prior to Java 8:
button.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
anInstanceOfYourOtherClass.yourMethod();
}
});
Upvotes: 6