title: How to store input data from GUI into ArrayList?
body: <p>Once the user enter vehicle name and Id and clicks Add Vehicle, you create a vehicle object and store it an an array list of vehicles.</p>
  
  <p>How to store input data from GUI into arraylist?</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.event.ActionEvent;
  import javafx.event.EventHandler;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import javafx.scene.control.Label;
  import javafx.scene.control.TextField;
  import javafx.scene.layout.GridPane;
  import javafx.stage.Stage;
  
  public class Main extends Application {
      public static void main(String[] args) {
          Application.launch(args);
      }
  
      @Override
      public void start(Stage primaryStage) throws Exception {
          GridPane gridPane = new GridPane();
  
          Label VehicleName = new Label("Vehicle Name ");
          TextField VehicleNameF = new TextField();
  
          Label Vehicle_ID = new Label("Vehicle ID");
          TextField VehicleID = new TextField();
  
          Button AddButton = new Button("Add Vehicle");
          gridPane.setHgap(15);
          gridPane.setVgap(15);
          gridPane.add(VehicleName, 0, 0);
          gridPane.add(Vehicle_ID, 0, 1);
          gridPane.add(VehicleNameF, 1, 0);
          gridPane.add(VehicleID, 1, 1);
          gridPane.add(AddButton, 1, 2, 2, 1);
  
          Scene scene = new Scene(gridPane, 300, 150);
          primaryStage.setScene(scene);
          primaryStage.show();
      }
  }
  </code></pre>