关于javaFX和Scene Builder的问题:我想将一个fx:id分配给一个按钮,我是通过循环创建的,因为我需要该按钮中的文本在另一个窗格上创建另一个标签 .

这是主要的课程

package People;

    import javafx.application.Application;
    import javafx.fxml.FXMLLoader;
    import javafx.scene.Parent;
    import javafx.scene.Scene;
    import javafx.stage.Stage;

    /**
     * Created by 2e3cr on 27/6/2017.
     */
    public class Main extends Application{
        @Override
        public void start(Stage primaryStage) throws Exception {
            Parent m =         FXMLLoader.load(getClass().getResource("eventGroup.fxml"));

            Scene scene = new Scene(m);

            primaryStage.setScene(scene);
            primaryStage.show();
        }

        public static void main(String[] args) {
            launch(args);
        }
    }

这是名为EventGroupController的FXML文件的控制器

package People;

    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.fxml.FXML;
    import javafx.fxml.Initializable;
    import javafx.scene.control.Button;
    import javafx.scene.control.Label;
    import javafx.scene.control.Separator;
    import javafx.scene.layout.AnchorPane;
    import javafx.scene.layout.Pane;
    import javafx.scene.layout.VBox;

    import java.net.URL;
    import java.util.ArrayList;
    import java.util.ResourceBundle;


    /**
     * Created by 2e3cr on 23/6/2017.
    */public class EventGroupController implements Initializable{

        @FXML
        private AnchorPane eventsInf;

        @FXML
        private Label eventName;

        @FXML
        private VBox events;

        ArrayList<String> eventsList = new ArrayList<String>();


        @Override
        public void initialize(URL location, ResourceBundle resources) {
            eventsList.add("event 1");
            eventsList.add("event 2");
            eventsList.add("event 3");
            eventsList.add("event 4");
            eventsList.add("event 5");
            eventsList.add("event 6");
            eventsList.add("event 7");
            eventsList.add("event 8");
            eventsList.add("event 9");

            Button btn;
            for(int i = 0; i < eventsList.size(); i++){
                btn = new Button(eventsList.get(i));
                btn.setPrefWidth(195);
                btn.setPrefHeight(100);
                btn.setStyle("-fx-background-color :  #808080");
                btn.setOnAction(new EventHandler<ActionEvent>() {
                    @Override
                    public void handle(ActionEvent event) {

                    }
                });
                events.getChildren().add(btn);

                Separator sep = new Separator();
                sep.setPrefWidth(200);
                sep.setPrefHeight(10);
                events.getChildren().add(sep);
            }



        }



    }

我的控制器目前看起来像这样

http://i.imgur.com/iAFrfYm.png

正如你所看到的,我希望左侧按钮的标签出现在右侧的标签上,但我不知道如何 . 请原谅我,如果这个问题已经得到解答,但我已经尝试使用谷歌搜索“如何将fx:id分配给循环生成的按钮”,但无济于事