Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 394
  • Last Modified:

detecting cancel button in JOptionpane

Hi!

is there any ways that I can detect when a user clicks cancel button and exit program

for example,

++++++
      public void setSubjectID(){
            subjectID = JOptionPane.showInputDialog(null, "Enter subject ID number: ",
                        null);
      }
+++++++++++
thanks,
0
dkim18
Asked:
dkim18
  • 2
1 Solution
 
CEHJCommented:
Check the retun value
0
 
OBCTCommented:
Use something like this...

if (subjectID == JOptionPane.CANCEL_OPTION)
{
   // do whatever
}
0
 
CEHJCommented:
8-)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now