title: Add MouseClick Event on ScrollPane in JavaFX
body: <p>I have created a Scroll Pane (with Anchor Pane) in JavaFX.
  On runtime I am creating a rectangle and adding it to the ScrollPane.
  I want to add a mouse click event on the scroll pane, in which I can change the contents of the scrollPane on runtime.</p>
  
  <p>I tried doing that but I get this exception when I click on the ScrollPane</p>
  
  <pre><code>Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: argument type mismatch
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  at java.lang.reflect.Method.invoke(Unknown Source)
  at sun.reflect.misc.Trampoline.invoke(Unknown Source)
  at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  at java.lang.reflect.Method.invoke(Unknown Source)
  at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
  at javafx.fxml.FXMLLoader$MethodHandler.invoke(Unknown Source)
  at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(Unknown Source)
  at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
  at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
  at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
  at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
  at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
  at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
  at javafx.event.Event.fireEvent(Unknown Source)
  at javafx.scene.Scene$ClickGenerator.postProcess(Unknown Source)
  at javafx.scene.Scene$ClickGenerator.access$7900(Unknown Source)
  at javafx.scene.Scene$MouseHandler.process(Unknown Source)
  at javafx.scene.Scene$MouseHandler.access$1500(Unknown Source)
  at javafx.scene.Scene.impl_processMouseEvent(Unknown Source)
  at javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
  at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
  at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
  at com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
  at com.sun.glass.ui.View.notifyMouse(Unknown Source)
  at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
  at com.sun.glass.ui.win.WinApplication.lambda$null$141(Unknown Source)
  at com.sun.glass.ui.win.WinApplication$$Lambda$37/1109371569.run(Unknown Source)
  at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>Here is my JavaFX fxml part,</p>
  
  <pre><code>&lt;ScrollPane fx:id="scrollPane" layoutX="229.0" layoutY="183.0" onMouseClicked="#ChangeImageColor" prefHeight="137.0" prefWidth="143.0"&gt;
         &lt;content&gt;
             &lt;AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="154.0" prefWidth="157.0" /&gt;
         &lt;/content&gt;
  &lt;/ScrollPane&gt;
  </code></pre>
  
  <p>And My Java Code,</p>
  
  <pre><code>@FXML
  void ChangeImageColor(ActionEvent event)
  {
      System.out.print("Hit!");
      scrollPane.setContent(null);
      Rectangle rectangle = new Rectangle(200, 200, Color.BLUEVIOLET);
      rectangle.setStroke(Color.BLACK);
      rectangle.setStrokeWidth(25);
      scrollPane.setContent(rectangle);           
  }
  </code></pre>
  
  <p>This is what i am doing on initialization,</p>
  
  <pre><code>Rectangle rectangle = new Rectangle(200, 200, Color.RED);
  rectangle.setStroke(Color.BLACK);
  rectangle.setStrokeWidth(25);
  scrollPane.setContent(rectangle);
  </code></pre>