How to catch the Event of JoptionPane

Hi experts,

following is a small snippet of my code

<snip>
try{
   CheckValueException.checkValues(lows_Datapass,
prtxt_Oldpass.getText());
  }
  catch(CheckValueException cve){
   int x = JOptionPane.showConfirmDialog(prfra_Main, "Password doesnt
match try again", "Error", JOptionPane.DEFAULT_OPTION);
   System.out.println("The int is " + x);
   prtxt_Oldpass.requestFocus();
  }
</snip>

After this joption message i want the entire program to terminate, but
after clicking the okay button it is moving to the next block.

How shall i implement that??  Please help me.

Thanks
Srini

seenuvAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jsridharCommented:
add the line:

System.exit(0);

at the place where you would wish the application to terminate.

js.
0
seenuvAuthor Commented:
no what i need is that i need the focus again to a textfiled system.exit(0) will make the window disappear and will terminate the whole application, but i need the application but the execution alone should terminate, say when i click theokay button i need the focus again to the textfield and the code should not move further.
0
jsridharCommented:
>>After this joption message i want the entire program to terminate, but
after clicking the okay button it is moving to the next block.

Since you wanted the "entire program to terminate" i suggested to add:

System.exit(0);

The general way of doing "wrong password" message boxes are:

1. show the error message dialog using:
JOptionPane.showMessageDialog
2. set the focus to the field and return from the function.

The code has to be written in the event handler code of the button.

Still it is not very clear as what you want!!!

js.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

seenuvAuthor Commented:
no what i need is that i need the focus again to a textfiled system.exit(0) will make the window disappear and will terminate the whole application, but i need the application but the execution alone should terminate, say when i click theokay button i need the focus again to the textfield and the code should not move further.
0
seenuvAuthor Commented:
sorry for posting that comment again it was not intentionally done, yes i now got some logic, u mean to say return true or false as per the output right??.

I shall take care sridhar thanks for ur assistance,  u propose this as an answer i shall accept it.

Thanks
Srini

ps EXPERTS PLEASE PROPOSE ANY ANSWER AS I SRIDHAR DESERVES POINTS.
0
jsridharCommented:
>>After this joption message i want the entire program to terminate, but
after clicking the okay button it is moving to the next block.

Since you wanted the "entire program to terminate" i suggested to add:

System.exit(0);

The general way of doing "wrong password" message boxes are:

1. show the error message dialog using:
JOptionPane.showMessageDialog
2. set the focus to the field and return from the function.

The code has to be written in the event handler code of the button.

Still it is not very clear as what you want!!!

js.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.