1

This is probably a simple error, but I can't figure it out. I can call getText on TextArea controls just fine, but TextField controls are constantly thowing an InvocationTargetException error. They are both defined in the same way and I've triple checked the FX IDs and controller is correct. Not sure what else could cause this. Please help!

Relevant FXML - Root Node

<VBox prefHeight="500.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="api.LayoutController">

Field FXML

<TextField fx:id="apitoken" text="mytopsecrettoken" GridPane.columnIndex="1">
<GridPane.margin><Insets /></GridPane.margin></TextField>

Controller:

public class LayoutController implements Initializable {

    @FXML
    private TextArea result,data;
    private TextField apitoken,object;

    @FXML
    private void submit(ActionEvent event) {   
          result.setText(apitoken.getText());                
    }

Exception information:

Executing C:\Users\XXX\Documents\NetBeansProjects\API\dist\run1375954609\API.jar using platform C:\Program Files\Java\jdk1.8.0_05\jre/bin/java
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1768)
    at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1651)
Rod_Algonquin
  • 26,074
  • 6
  • 52
  • 63
JavaMark
  • 11
  • 1
  • Wow, this was embarrassing. The error was due to the missing "@FXML" declaration for the TextField variables. The link below contains more information on the answer. Search for the FMXL section header in blue. http://docs.oracle.com/javase/8/javafx/api/javafx/fxml/doc-files/introduction_to_fxml.html – JavaMark Jun 09 '14 at 01:04

0 Answers0