I have a Main page in java FX with a table view that is populated with an observable list of a class titled Parts.
I want to be able to select a row on this table and press the modify button. pressing the modify button switches to the "modify Part Scene" which has TextFields for the various parameters of the part; name, cost, inventory, min and max quantity.
I want the part I had selected in the Main scene to be populated in the modify part scene TextFields.
I can't figure out how to have the "Part" I selected transfer to the Modify part Scene.
I have tried having the Modify part Controller extend the Main controller class and implement the Initializable interface, then override the Initialize method on the part modifier controller to take
" @FXML TextField name;
@FXML TextField inventory;
@FXML TextField price;
@FXML TextField min;
@FXML TextField max;
public void initialize (URL url, ResourceBundle resourceBundle){
name.setText(partTableView.getSelectionModel().getSelectedItem().getName());
}"
but I get the warning
"Caused by: java.lang.NullPointerException: Cannot invoke "javafx.scene.control.TableView.getSelectionModel()" because "this.partTableView" is nullat com.example.InventoryManager/com.example.InventoryManager.ModifyPartController.initialize(ModifyPartController.java:40)"
because the selection on the main scene isn't carried over when the scene switches. im not sure how I am supposed to get the selected part transferred to the next scene and I need it to be the same instance of the selected part from the observable list so that when I save the modification the selected part is updated in the list.