I'm decently new to Java. I want the user to be able to input 4 different inputs separately by clicking submit. I'm using a for loop to count, but I do not know how to have the user input their answer multiple times. The for loops just repeats all at once. I'm using arrays to hold the user's answers. Here is part of my code. If you have questions or need more explanation I will def. explain more
private void Question1()
{
int count = 1;
QuestionsPanel.add(new JLabel(Q1.getQuestion()));
QuestionsPanel.add(new JLabel(Arrays.toString(mans1)));
AnswerField = new JTextField(10);
AnswerPanel.add(AnswerField);
Submit = new JButton("Submit");
AnswerPanel.add(Submit);
Submit.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if ((e.getSource() == Submit) && count == 0)
{
int value = Integer.parseInt(AnswerField.getText());
for (int i = 0; i < 4; i++)
{
if (value == -1) break;
ans[i] = value - 1;
AnswerField.setText("");
}