Last active
December 1, 2018 21:52
-
-
Save zachomedia/4365663 to your computer and use it in GitHub Desktop.
Example demonstrating how to get the return value from a confirm dialog.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.*; | |
import java.awt.event.*; | |
import javax.swing.*; | |
public class JOptionPaneExample | |
{ | |
public static void main(String [] args) | |
{ | |
int returnValue = 0; | |
returnValue = JOptionPane.showConfirmDialog(null, "Are you sure you want to exit?", "Are you sure?", JOptionPane.YES_NO_OPTION); | |
if (returnValue == JOptionPane.YES_OPTION) | |
JOptionPane.showMessageDialog(null, "Yes was clicked."); | |
else if (returnValue == JOptionPane.NO_OPTION) | |
JOptionPane.showMessageDialog(null, "No was clicked."); | |
}//End of main method | |
}//End of class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!