joptionpane.showconfirmdialog yes no example

Java
int answer = JOptionPane.showConfirmDialog(parentComponent, 
		"Your message goes here", "Your title goes here", 
        JOptionPane.YES_NO_OPTION);

if (answer == JOptionPane.NO_OPTION) {
	// do something
} else if(answer == JOptionPane.YES_OPTION) {
  	// do something else
}
Source

Also in Java: