Java tutorial
import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JOptionPane; public class Main { public static void main(String[] args) { JComponent parentComponent = null; Object message = "How is JOptionPane?"; String title = "JOptionPane Option Dialog"; int messageType = JOptionPane.INFORMATION_MESSAGE; Icon icon = null; Object[] options = new String[] { "A", "B", "C" }; Object initialOption = options[2]; int response = JOptionPane.showOptionDialog(null, message, title, JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, icon, options, initialOption); switch (response) { case 0: case 1: case 2: System.out.println("we selected:" + options[response]); break; case JOptionPane.CLOSED_OPTION: System.out.println("we closed the dialog box."); break; default: System.out.println("I don't know what we did."); } } }