JavaFX 2.0 - create action handler for custom component in FXML
问题 I want to add a custom action in my new component. How to do this? Example code: Component public class MyCustomComponent extends Region { public MyCustomComponent(){ super(); this.setOnMouseClicked(new EventHandler<MouseEvent>(){ @Override public void handle(MouseEvent event) { /* throw my custom event here and handle it in my FXML controller - but how? :-( */ } }); } } Controller public class MyController { @FXML protected void myCustomAction(ActionEvent event) { // do something } } FXML: