Hello all,
is there a way to cancel or abort the execution of current actionPerformed? My problem is that, when the control is passed to the listener method, i perform checking if certain value is null, if so, display Error Msg using JOP. when user click OK, then the actionPerformed method should stop from executing the rest of the statements.. i use the System.exit(1).. but it terminated the app. Below is the code:
public void actionPerformed(ActionEvent nextbtn)
{
Object source = nextbtn.getSource();
if(source==btnNext)
{
String stuAnswer = txtAnswer.getText();
if(stuAnswer.equals(" "))
{
JOptionPane.showMessageDialog(this, "You have to input an Answer!",
"Empty Answer Detected..",
JOptionPane.ERROR_MESSAGE);
System.exit(1);
}
else
{
String questions = questionInput.nextLine();
lblQuestion.setText(questions);
studentAnswer[count] = txtAnswer.getText();
count++;
txtAnswer.setText("");
if(count>=9)
{
btnNext.setEnabled(false);
btnScore.setEnabled(true);
}
}
}