• Post Reply Bookmark Topic Watch Topic
  • New Topic

JOptionPane Problem...

 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I have a JOptionPane that is giving the user options of OK and CANCEL. I am trying to execute code based on what the user presses, but can't get it to work and I can't seem to figure out what I'm doing wrong.
Here's my code:

When I press cancel, the code doesn't execute.
I printed out the value of "value" and it displays as 1. When I printed out the value of "CANCEL_OPTION" it is equal to 2.
Why isn't this working? I guess I don't understand exactly how int's are assigned for the different fields of JOptionPane and how to use them properly.
Could someone please help me?
Thanks!
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Jennifer,
try

cheers,
Chantal
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!