title: Better way for Getting id of the clicked Object in JavaFX controller
body: <p>I`m looking for a better way for getting the id of the clicked object inside the event handler for this object.</p>
  
  <p>I already found this:</p>
  
  <p><a href="https://stackoverflow.com/questions/14085076/javafx-pass-fxid-to-controller-or-parameter-in-fxml-onaction-method">javafx pass fx:id to controller or parameter in fxml onAction method</a></p>
  
  <p>But that did not work for me.</p>
  
  <p>Now I'm using the getId() function of the node class like this:</p>
  
  <pre><code>Button btn = (Button) event.getSource();
  String id = btn.getId();
  </code></pre>
  
  <p>But i want to use this method not only for buttons.</p>