title: Listen for mouse clicked on a textfield in JavaFX FXML
body: <p>(Solved)I am using scene builder and FXML, and I am trying to make it so that if the user clicks on a text field, it enables that text field for editing and disables another text field. I can't seem to figure out how to make an action event that listen for the click of a mouse in a text field, and all the questions I've seen posted are for FX, not FXML. </p>
  
  <p>This is the code I have so far:</p>
  
  <pre><code>@FXML
      public void radiohandleBW(MouseEvent event){
          if(event.getSource() == fullBW){ //I think this line is throwing the error
              if(fullBW.isPressed()){
                  System.out.println("pressed");
              }
          }
      }
  </code></pre>
  
  <p>And here's the compiler error with it:</p>
  
  <pre><code>Executing D:\My Documents\NetBeansProjects\Statgain0.0.1\dist\run867462295\Statgain0.0.1.jar using platform C:\Program Files\Java\jdk1.8.0_131\jre/bin/java
  Exception in Application start method
  java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
      at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
  Caused by: java.lang.RuntimeException: Exception in Application start method
      at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
      at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
      at java.lang.Thread.run(Thread.java:748)
  Caused by: javafx.fxml.LoadException: Error resolving onAction='#radiohandleBW', either the event handler is not in the Namespace or there is an error in the script.
  file:/D:/My%20Documents/NetBeansProjects/Statgain0.0.1/dist/run867462295/Statgain0.0.1.jar!/statgain0/pkg0/pkg1/FXMLStatgain0.0.1.fxml:45
  
      at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2597)
      at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:103)
      at javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:610)
      at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:770)
      at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2823)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2532)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
      at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
      at statgain0.pkg0.pkg1.Statgain001.start(Statgain001.java:25)
      at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
      at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
      at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
      at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
      ... 1 more
  Exception running application statgain0.pkg0.pkg1.Statgain001
  Java Result: 1
  Deleting directory D:\My Documents\NetBeansProjects\Statgain0.0.1\dist\run867462295
  jfxsa-run:
  BUILD SUCCESSFUL (total time: 5 seconds)
  </code></pre>
  
  <p>If I am doing something wrong please tell me, I know it is more than just a simple fix.</p>