Created
May 26, 2013 06:45
-
-
Save aikchun/5651914 to your computer and use it in GitHub Desktop.
This OptionPane is to show how to customize JOptionPane showOptionDialog with YES_NO_OPTION
This file contains 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.util.*; | |
import javax.swing.*; | |
import java.awt.*; | |
import java.io.*; | |
public class OptionPane { | |
public static void main(String []args){ | |
Object[] options = { "OK", "Cancel" }; | |
int choice = JOptionPane.showOptionDialog(null, "Do you want to quit?", | |
"Exiting", | |
JOptionPane.YES_NO_OPTION, | |
JOptionPane.QUESTION_MESSAGE, | |
null, | |
options, | |
options[0]); | |
// interpret the user's choice | |
if (choice == JOptionPane.YES_OPTION) | |
// yes option; | |
else | |
// no option | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment