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);
									}
								}

				}

You really don't need to cancel execution of the method, just don't perform any other actions after the display of the message. It looks like your current method will do that just fine as it is. Just remove the System.exit() call.

Actually things could be much simpler... duno why i always come up w/ complicated ways..I removed the system.exit(1).. and after user press OK of the JOP, the control is passed back to the current frame w/o advancing to the next frame... forgive me for my complete ignorance... need to read more...

Thanks Ezzarral...just figured it out... Thankies :-)

This question has already been answered. Start a new discussion instead.