I am getting a runtime exception for this simple program i wrote. Exception occurs while "event" method is envoked(I think)
example.java
public class Example extends Application {
@Override
public void start(Stage primaryStage) {
try {
Parent roo11 = FXMLLoader.load(getClass().getResource("example.fxml"));
Scene scene = new Scene(roo11);
primaryStage.setTitle("D-A-S-H Messenger");
primaryStage.setScene(scene);
primaryStage.show();
} catch (IOException ex) {
Logger.getLogger(Example.class.getName()).log(Level.SEVERE, null, ex);
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
example.fxml
ExampleController.java
public class ExampleController {
@FXML JFXTextArea area;
@FXML JFXTextField field;
@FXML ImageView img;
@FXML public void event(MouseEvent e){
field.setOnMouseClicked((MouseEvent event) ->
{
area.setText("Hello\n");
});
}
}
Whenever I click the textfield exception occurs:
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException