Im working on some card game in java. I'm using javaFX for an user inteface but i have a little problem with it. I have 25 buttons and i would like to add text to all of them. I have done it but the code is ugly and very long. I'm using scenebuilder and I created button there, every button has uniqe id from 1 to 25. Is there any way to shorten this code?
@FXML
Button card1;
@FXML
Button card2;
@FXML
Button card3;
@FXML
Button card4;
@FXML
Button card5;
@FXML
Button card6;
@FXML
Button card7;
@FXML
Button card8;
@FXML
Button card9;
@FXML
Button card10;
@FXML
Button card11;
@FXML
Button card12;
@FXML
Button card13;
@FXML
Button card14;
@FXML
Button card15;
@FXML
Button card16;
@FXML
Button card17;
@FXML
Button card18;
@FXML
Button card19;
@FXML
Button card20;
@FXML
Button card21;
@FXML
Button card22;
@FXML
Button card23;
@FXML
Button card24;
@FXML
Button card25;
@FXML
public void initialize(){
Board board = new Board();
board.createBoard();
card1.setText(board.getListFields().get(0).getWord().name());
card2.setText(board.getListFields().get(1).getWord().name());
card3.setText(board.getListFields().get(2).getWord().name());
card4.setText(board.getListFields().get(3).getWord().name());
card5.setText(board.getListFields().get(4).getWord().name());
card6.setText(board.getListFields().get(5).getWord().name());
card7.setText(board.getListFields().get(6).getWord().name());
card8.setText(board.getListFields().get(7).getWord().name());
card9.setText(board.getListFields().get(8).getWord().name());
card10.setText(board.getListFields().get(9).getWord().name());
card11.setText(board.getListFields().get(10).getWord().name());
card12.setText(board.getListFields().get(11).getWord().name());
card13.setText(board.getListFields().get(12).getWord().name());
card14.setText(board.getListFields().get(13).getWord().name());
card15.setText(board.getListFields().get(14).getWord().name());
card16.setText(board.getListFields().get(15).getWord().name());
card17.setText(board.getListFields().get(16).getWord().name());
card18.setText(board.getListFields().get(17).getWord().name());
card19.setText(board.getListFields().get(18).getWord().name());
card20.setText(board.getListFields().get(19).getWord().name());
card21.setText(board.getListFields().get(20).getWord().name());
card22.setText(board.getListFields().get(21).getWord().name());
card23.setText(board.getListFields().get(22).getWord().name());
card24.setText(board.getListFields().get(23).getWord().name());
card25.setText(board.getListFields().get(24).getWord().name());
}```