title: Adding EventHandler To ImageView contained in a Label
body: <p>I have recently started exploring Java FX and want to create a custom label which will have an ImageView inside it.</p>
  
  <p>This is the code for my custom label.</p>
  
  <pre><code>Image image = new Image(getClass().getResourceAsStream("/img/remove.png"), 20, 20, true, true);
  ImageView removeImageView = new ImageView(image);
  
  Label customLabel = new Label(labelText, removeImageView);
  customLabel.setFont(Font.font("Arial", FontWeight.BOLD, 20));
  </code></pre>
  
  <p>This is how my custom label looks.</p>
  
  <p><a href="https://i.stack.imgur.com/F43E6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F43E6.png" alt="enter image description here"></a></p>
  
  <p>Now I want to add a mouse click EventHandler to the ImageView. This is my code for handling the mouse clicks.</p>
  
  <pre><code>removeImageView.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler&lt;MouseEvent&gt;() {
        @Override
        public void handle(MouseEvent event) {
          System.out.println("Imageview Clicked");
        }
      });
  </code></pre>
  
  <p>But when I am clicking on the <code>cross</code> image, the event is not getting captured.</p>
  
  <p>I experimented a bit and tried to add an EventHandler to the <code>customLabel</code>. The label was able to capture the mouse click.</p>
  
  <p>It seems to me that I am facing this issue because the ImageView is contained within the Label. What I want to know is, is this a limitation to JFX or is there any alternative way to achieve this functionality. Thanks.</p>