I am currently facing an issue where I have an ArrayList
of answers to a question and I am trying to print out each answer to a JLabel as this will display the question being added to the question bank.
The problem is it will only print one answer and there could be 5 answers stored in the array. It is printing it to the console I have tried putting this.add(answerLabel);
inside the for loop and outside.
Am I approaching this the best way?
answerLabel = new JLabel();
answerLabel.setBounds(100, 100, 300, 300);
for (int i = 0; i < answers.size(); i++) {
answerLabel.setText("Answer " + i + ": " + answers.get(i));
System.out.println("Answer " + i + ": " + answers.get(i));
this.add(answerLabel);
}