Java tutorial
import javax.swing.JOptionPane; public class Main { public static void main(String[] args) { int response = JOptionPane.showConfirmDialog(null, "Save the file?", "Confirm Save Changes", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); switch (response) { case JOptionPane.YES_OPTION: System.out.println("yes"); break; case JOptionPane.NO_OPTION: System.out.println("no"); break; case JOptionPane.CANCEL_OPTION: System.out.println("cancel"); break; case JOptionPane.CLOSED_OPTION: System.out.println("closed."); break; default: System.out.println("something else"); } } }