I have a JOptionPane set when a certain action happens, and I want it to be showMessageDialog because that just displays a message. How do I make it so when you click OK or cancel, it closes the entire application?
This is what I put
JOptionPane.showMessageDialog(null, "you lose");
if (JOptionPane.OK_OPTION){
System.exit(0);
}
but it doesnt work. I based it off of this code I found online:
int exit = JOptionPane.showConfirmDialog(mainFrame, "Are you sure?");
if (exit == JOptionPane.YES_OPTION)
{
try
{
Runtime.getRuntime().exec("cmd.exe /c start www.yahoo.com");
}
catch (Exception exception)
{
}
System.exit(0);
}
else {
}
But that is for a Confirm dialog and I just want it to work for Message dialog.
I tried changing JOptionFrame.showConfirmDialog to JOptionFrame.showMessageDialog but it doesnt work, as int and other stuff had to be deleted.
Thanks