I want to display 5 different comments when a button (Answer Btn) is clicked.
Here we can see the JOption message dialog showing "Correct" comment.
When I click the Answer button again, I want it to display another comment like "Great Job".
Here is the code for my ansBtnListener
class ansBtnListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
// checking answer is correct or wrong
double doubleOfInput = Double.parseDouble(input.getText()); // getting string to double
if (doubleOfInput == result) {
JOptionPane.showMessageDialog(null, "Correct");
} else {
JOptionPane.showMessageDialog(null, "Wrong, Try Again!");
input.setText(" ");
}
}
}
Any help is much appreciated.