@Override public void actionPerformed(ActionEvent arg) { String mes = ""; int it = 1; // for all of the answers of the challenger check if its true or false // add points if he answered good // add the good answers if not // and show it in a dialogBox. for (AnswerUI ans : QuestionnaireUI.this.answers) { if (ans.getAnswer().checkAnswer(ans.getValue())) QuestionnaireUI.this.points += ans.getQuestion().getPoints(); else mes += "Q" + it + " : Wrong the correct answer was : " + ans.getAnswer().getCorrectAnswer() + "\n"; it++; } mes += "\nYou have won " + QuestionnaireUI.this.points + " points"; JOptionPane.showMessageDialog(frame, mes); }