Skip to content

Instantly share code, notes, and snippets.

@aikchun
Created May 26, 2013 06:45
Show Gist options
  • Save aikchun/5651914 to your computer and use it in GitHub Desktop.
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
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