title: JavaFX 2.0 - create action handler for custom component in FXML
body: <p>I want to add a custom action in my new component. 
  How to do this?</p>
  
  <p>Example code:</p>
  
  <p>Component</p>
  
  <pre><code>public class MyCustomComponent extends Region {
      public MyCustomComponent(){
          super();
  
          this.setOnMouseClicked(new EventHandler&lt;MouseEvent&gt;(){
  
              @Override
              public void handle(MouseEvent event) {
                  /* throw my custom event here and handle it in my FXML controller - but how? :-(  */
              }
          });
      }
  }
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>public class MyController {
      @FXML protected void myCustomAction(ActionEvent event) {
          // do something
      }
  }
  </code></pre>
  
  <p>FXML:</p>
  
  <pre><code>&lt;BorderPane fx:controller="fxmlexample.MyController" 
      xmlns:fx="http://javafx.com/fxml"&gt;
       &lt;top&gt;
          &lt;MyCustomComponent onAction="#myCustomAction"&gt;
          &lt;/MyCustomComponent&gt;
       &lt;/top&gt;
  &lt;/BorderPane&gt;
  </code></pre>
  
  <p>Thx for help</p>