javafx中java.lang.reflect.InvocationTargetException中的异常

javafx中java.lang.reflect.InvocationTargetException中的异常,java,exception,javafx,invocationtargetexception,Java,Exception,Javafx,Invocationtargetexception,你能帮我解决这个错误吗。我一直在想问题出在哪里。 也许是我没见过的东西。这是一个非常简单的程序。我在java方面没有太多经验 这是代码 public class StudentInfo extends Application { @Override // Override the start method in the Application class public void start(Stage primaryStage) { // Create a pane and set

你能帮我解决这个错误吗。我一直在想问题出在哪里。 也许是我没见过的东西。这是一个非常简单的程序。我在java方面没有太多经验

这是代码

public class StudentInfo extends Application {
@Override // Override the start method in the Application class
  public void start(Stage primaryStage) {
    // Create a pane and set its properties

    BorderPane mainpane = new BorderPane();
    GridPane leftpane = new GridPane();
    leftpane.setAlignment(Pos.CENTER);
    leftpane.setPadding(new Insets(11.5, 12.5, 13.5, 14.5));
    leftpane.setHgap(5);
    leftpane.setVgap(5.5);
    //FlowPane pane = new FlowPane(Orientation.VERTICAL);
    //pane.setPadding(new Insets(11, 12, 13, 14));
    //pane.setHgap(5);
    //pane.setVgap(5);

    //String[] computerCourses = {"Select a course","Python", "C#", "Dephi","Java","XML"};
    //String[] businessCourses = {"Select a course","Finance","Marketing","Investment Analysis","Business Communications"};

    // Place nodes in the pane

    Label lblName = new Label("Name:");
    Label lblAddress = new Label("Adress:");
    Label lblProvince = new Label("Province");
    Label lblCity = new Label("City:");
    Label lblPostalCode = new Label("Postal Code:");
    Label lblPhoneNumber = new Label("Phone number:");
    Label lblEmail = new Label("Email:");

    //VBox vBox = new VBox(5);
    //vBox.setPadding(new Insets(15, 5, 5, 5));
    //vBox.getChildren().add(lblName);
    //vBox.getChildren().add(lblAddress);
    //vBox.getChildren().add(lblProvince);
    //vBox.getChildren().add(lblCity);
    //vBox.getChildren().add(lblPostalCode);
    //vBox.getChildren().add(lblPhoneNumber);
    //vBox.getChildren().add(lblEmail);

    //mainpane.setLeft(vBox);
    TextField tfName = new TextField();
    TextField tfAddress = new TextField();
    TextField tfProvince = new TextField();
    TextField tfCity = new TextField();
    TextField tfPostalCode = new TextField();
    TextField tfPhoneNumber = new TextField();
    TextField tfEmail = new TextField();

    leftpane.add(lblName, 0, 0);
    leftpane.add(tfName, 1, 0);
    leftpane.add(lblAddress, 0, 1); 
    leftpane.add(tfAddress, 1, 1);
    leftpane.add(lblProvince, 0, 2);
    leftpane.add(tfProvince, 1, 2);
    leftpane.add(lblPhoneNumber, 0, 3);
    leftpane.add(tfPhoneNumber, 1, 3);
    leftpane.add(lblCity, 0, 4);
    leftpane.add(tfCity, 1, 4);
    leftpane.add(lblPostalCode, 0, 5);
    leftpane.add(tfPostalCode, 1, 5);
    leftpane.add(lblPhoneNumber, 0, 6);
    leftpane.add(tfPhoneNumber, 1, 6);
    leftpane.add(lblEmail, 0, 7);
    leftpane.add(tfEmail, 1, 7);

    mainpane.setLeft(leftpane);
    //Button btDisplay = new Button("Display");

    //CheckBox chkStudentCouncil = new CheckBox("Bold");
    //CheckBox chkVolunteerWork = new CheckBox("Bold");

    //RadioButton rbComputerScience = new RadioButton("Computer Science");
    //RadioButton rbBusiness = new RadioButton("Business"); 
    //ComboBox<String> cbCourses = new ComboBox<>();
    //ListView<String> lvCourses = new ListView<>(); 
    //pane.getChildren().addAll(lblName, lblAddress, lblProvince, lblCity, lblPostalCode, lblPhoneNumber, lblEmail); 

    // Create a scene and place it in the stage
    Scene scene = new Scene(mainpane, 1000, 300);
    primaryStage.setTitle("Student Information"); // Set the stage title
    primaryStage.setScene(scene); // Place the scene in the stage
    primaryStage.show(); // Display the stage
  }

  /**
   * The main method is only needed for the IDE with limited
   * JavaFX support. Not needed for running from the command line.
   */
  public static void main(String[] args) {
    launch(args);
  }
提前感谢你们的帮助

问题在这里:

leftpane.add(lblPhoneNumber, 0, 6);
leftpane.add(tfPhoneNumber, 1, 6);
您已经在此处添加了lblPhoneNumber:

leftpane.add(lblPhoneNumber, 0, 3);
leftpane.add(tfPhoneNumber, 1, 3);

由:java.lang.IllegalArgumentException:Children:duplicate Children added引起的异常
,只是试图告诉您不能在网格的另一个位置再次添加相同的对象

非常感谢你。这是一个简单的复制粘贴错误。我想我看不见是因为我觉得太累了。
leftpane.add(lblPhoneNumber, 0, 3);
leftpane.add(tfPhoneNumber, 1, 3);