public class Main { public static void main(String[] argv) throws Exception {
JFrame frame = new JFrame();
String message = "message"; int answer = JOptionPane.showConfirmDialog(frame, message); if (answer == JOptionPane.YES_OPTION) {
// User clicked YES.
} else if (answer == JOptionPane.NO_OPTION) {
// User clicked NO.
}
}
}