I have created a custom exit button and i want the code to terminate if that button is pressed. How can i achieve that?
String[] button1 = {"exit", "next"};
//if next is pressed
if (code == JOptionPane.YES_OPTION) {
JOptionPane.showMessageDialog(
null,
"Knock knock" + "\nWho is there",
"The Jasmin Project",
JOptionPane.YES_NO_OPTION);
int no = JOptionPane.showOptionDialog(null, "Want to view more?",
"The Jasmin Project",
JOptionPane.YES_NO_OPTION,
JOptionPane.INFORMATION_MESSAGE,
null,
button1,
button1[0]);
//end code if exit is pressed
if (no == JOptionPane.NO_OPTION) {
System.exit(1);
}
}