0

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.

  • 2
    [mcve] please .. – kleopatra Mar 19 '23 at 23:44
  • Maybe the ideas from [here](https://stackoverflow.com/questions/50653235/show-tableview-data-into-another-window-contains-textfield-in-javafx/50653518#50653518) or [here](https://stackoverflow.com/questions/55668795/javafx-2-independent-windows-at-once/55671730#55671730) can help. – SedJ601 Mar 20 '23 at 00:45
  • Just [pass the selected value to the new controller](https://stackoverflow.com/questions/14187963/passing-parameters-javafx-fxml) – James_D Mar 20 '23 at 02:48

0 Answers0