I've got an NullPointerException which occures in this file:
Caused by: java.lang.reflect.InvocationTargetException
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(FXMLLoader.java:1771)
... 48 more
Caused by: java.lang.NullPointerException
at Controller.RocketController.addItem(RocketController.java:55)
at Controller.SurvayController.acceptButtonClicked(SurvayController.java:45)
Here is the part of code which probably is causing an error
RocketController:
public void addItem(Aims aim)
{
ArrayList<Aims> list = new ArrayList();
list.add(aim);
ObservableList<Aims> observableList = FXCollections.observableList(list);
listView.setItems(observableList);
}
This function is triggered by a button in another stage:
SurvayController:
@FXML
void acceptButtonClicked()
{
Aims newAim = new Aims(directionField.getText(),comboBox.getSelectionModel().getSelectedItem(),distanceField.getText(),speedField.getText());
rocketController.addItem(newAim);
Stage stage=(Stage) speedField.getScene().getWindow();
stage.close();
}
Have you got any ideas why i get this ?