How to handle the Cancel button on JOptionPane.showInputDialog

  • Follow


I have a input dialog that gets the password. When i enter a value and
click OK it works fine. But when i click Cancel i get a Null Pointer
Exception. How to handle the Cancel button

Any help in this regard would be greatly apprecialted

thanks in advance
Bala
0
Reply pb_subramanian 9/30/2004 1:52:25 PM

On 30 Sep 2004 06:52:25 -0700, Bala wrote:

> But when i click Cancel i get a Null Pointer
> Exception. How to handle the Cancel button..

Catch it.

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.lensescapes.com/  Images that escape the mundane
0
Reply Andrew 9/30/2004 2:22:18 PM


The api say:
Returns:
user's input, or null meaning the user canceled the input

so test before use on null

-- 
D.G. Oort
"Bala" <pb_subramanian@myway.com> schreef in bericht 
news:5a9c5234.0409300552.35ce511b@posting.google.com...
>I have a input dialog that gets the password. When i enter a value and
> click OK it works fine. But when i click Cancel i get a Null Pointer
> Exception. How to handle the Cancel button
>
> Any help in this regard would be greatly apprecialted
>
> thanks in advance
> Bala 


0
Reply Dirk 9/30/2004 2:26:36 PM

Bala wrote:

> I have a input dialog that gets the password. When i enter a value and
> click OK it works fine. But when i click Cancel i get a Null Pointer
> Exception. How to handle the Cancel button

Detect the null and deal with it. One way to deal with it is to assume it
meant the user pressed "Cancel".

-- 
Paul Lutus
http://www.arachnoid.com

0
Reply Paul 9/30/2004 3:02:25 PM

3 Replies
851 Views

(page loaded in 0.343 seconds)

Similiar Articles:













7/22/2012 2:12:56 AM


Reply: