Something like is what everyone means when they say you should create those items in java and not in fxml
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
GridPane gridPane = new GridPane();
//This is so you can access them later
ArrayList<Button> buttonList = new ArrayList<>();
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 5; j++) {
Button button = new Button();
button.setText("Card:"+i*j);
button.setPrefSize(80,120);
//If you need to know what card it is add the below line
button.setId(String.valueOf(i*j));
buttonList.add(button);
gridPane.add(button, i, j);
}
}
Scene scene = new Scene(gridPane);
primaryStage.setScene(scene);
primaryStage.show();
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…