title: javafx.fxml.LoadException: Error resolving onAction='#getText', either the event handler is not in the Namespace or there is an error in the script
body: <p>Beginner with JavaFX, please help me, my code keeps throwing this error. Also, my buttonClick method throws a warning "The type ActionEvent from module javafx.base may not be accessible to clients due to missing 'requires transitive'".</p>
  
  <p>I've tried importing different ActionEvent and EventHandler</p>
  
  <p>My FXML code</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import javafx.scene.control.Button?&gt;
  &lt;?import javafx.scene.control.TextField?&gt;
  &lt;?import javafx.scene.layout.ColumnConstraints?&gt;
  &lt;?import javafx.scene.layout.GridPane?&gt;
  &lt;?import javafx.scene.layout.RowConstraints?&gt;
  &lt;?import javafx.scene.text.Font?&gt;
  &lt;?import javafx.scene.text.Text?&gt;
  
  &lt;GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.SampleController"&gt;
    &lt;columnConstraints&gt;
      &lt;ColumnConstraints hgrow="SOMETIMES" maxWidth="360.0" minWidth="10.0" prefWidth="301.0" /&gt;
      &lt;ColumnConstraints hgrow="SOMETIMES" maxWidth="345.0" minWidth="10.0" prefWidth="299.0" /&gt;
    &lt;/columnConstraints&gt;
    &lt;rowConstraints&gt;
        &lt;RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /&gt;
      &lt;RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /&gt;
      &lt;RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /&gt;
      &lt;RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /&gt;
    &lt;/rowConstraints&gt;
     &lt;children&gt;
        &lt;Text fx:id="celsius" strokeType="OUTSIDE" strokeWidth="0.0" text="Celsius:" textAlignment="CENTER" wrappingWidth="300.611328125"&gt;
           &lt;font&gt;
              &lt;Font name="Britannic Bold" size="36.0" /&gt;
           &lt;/font&gt;
        &lt;/Text&gt;
        &lt;Text fx:id="fahrenheit" strokeType="OUTSIDE" strokeWidth="0.0" text="Fahrenheit:" textAlignment="CENTER" wrappingWidth="302.3359375" GridPane.rowIndex="1"&gt;
           &lt;font&gt;
              &lt;Font name="Britannic Bold" size="36.0" /&gt;
           &lt;/font&gt;
        &lt;/Text&gt;
        &lt;Text fx:id="kelvin" strokeType="OUTSIDE" strokeWidth="0.0" text="Kelvin:" textAlignment="CENTER" wrappingWidth="302.490234375" GridPane.rowIndex="2"&gt;
           &lt;font&gt;
              &lt;Font name="Britannic Bold" size="36.0" /&gt;
           &lt;/font&gt;
        &lt;/Text&gt;
        &lt;TextField fx:id="textBox" alignment="CENTER" onAction="#getText" text="0" GridPane.columnIndex="1"&gt;
           &lt;font&gt;
              &lt;Font name="Britannic Bold" size="36.0" /&gt;
           &lt;/font&gt;
        &lt;/TextField&gt;
        &lt;Text fx:id="fahrenheitNumber" strokeType="OUTSIDE" strokeWidth="0.0" text="0" textAlignment="CENTER" wrappingWidth="300.97265625" GridPane.columnIndex="1" GridPane.rowIndex="1"&gt;
           &lt;font&gt;
              &lt;Font name="Britannic Bold" size="36.0" /&gt;
           &lt;/font&gt;
        &lt;/Text&gt;
        &lt;Text fx:id="kelvinNumber" strokeType="OUTSIDE" strokeWidth="0.0" text="0" textAlignment="CENTER" wrappingWidth="299.97265625" GridPane.columnIndex="1" GridPane.rowIndex="2"&gt;
           &lt;font&gt;
              &lt;Font name="Britannic Bold" size="36.0" /&gt;
           &lt;/font&gt;
        &lt;/Text&gt;
        &lt;Button fx:id="button" mnemonicParsing="false" onAction="#buttonClick" prefHeight="25.0" prefWidth="576.0" text="Convert Now!" translateX="10.0" GridPane.columnSpan="2" GridPane.rowIndex="3"&gt;
           &lt;font&gt;
              &lt;Font name="Britannic Bold" size="39.0" /&gt;
           &lt;/font&gt;
        &lt;/Button&gt;
     &lt;/children&gt;
  &lt;/GridPane&gt;
  </code></pre>
  
  <p>My controller class</p>
  
  <pre><code>package application;
  
  import javafx.fxml.FXML;
  import javafx.scene.control.Button;
  import javafx.scene.control.TextField;
  import javafx.scene.text.Text;
  import javafx.event.ActionEvent;
  
  public class SampleController {
      @FXML
      private Button button;
      @FXML
      private Text celsius;
      @FXML
      private Text fahrenheit;
      @FXML
      private Text kelvin;
      @FXML
      private Text fahrenheitNumber;
      @FXML
      private Text kelvinNumber;
      @FXML
      private TextField textBox;
  
      public void buttonClick(ActionEvent event) {
          int x = Integer.parseInt(textBox.getText());
          fahrenheitNumber.setText(Integer.toString(x * (9 / 5) + 32));
          kelvinNumber.setText(Double.toString(x + 273.15));
      }
  }
  </code></pre>
  
  <p>A window should be shown but instead, this is thrown.</p>
  
  <p>javafx.fxml.LoadException: Error resolving onAction='#getText', either the event handler is not in the Namespace or there is an error in the script.
  /C:/Users/user/eclipse-workspace/JavaFXSceneBuilder/bin/application/Sample.fxml:42</p>
  
  <pre><code>at javafx.fxml/javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2621)
  at javafx.fxml/javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:105)
  at javafx.fxml/javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:618)
  at javafx.fxml/javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:778)
  at javafx.fxml/javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2838)
  at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2557)
  at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2466)
  at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3237)
  at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3194)
  at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3163)
  at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3136)
  at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3113)
  at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:3106)
  at hellofxmlcode/application.Main.start(Main.java:14)
  at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
  at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
  at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
  at java.base/java.security.AccessController.doPrivileged(Native Method)
  at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
  at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
  at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
  at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
  at java.base/java.lang.Thread.run(Thread.java:834)
  </code></pre>