Im creating a quiz game using the JOption panes for my computer programming 1 class but I cant figure out this one detail. This is what I have so far:
import javax.swing.JOptionPane; public class FinalProject { public static void main(String[] args) { JOptionPane.showMessageDialog(null, "Welcome to my Sports Quiz, on the next window, you will be prompted to continue."); JOptionPane.showConfirmDialog(null, "Play?", "Sports Quiz", JOptionPane.YES_NO_OPTION); //int YesNo = 1; Switch (YesNo); { case yes : JOptionPane.YES_OPTION: System.out.print("Good"); break; case no : JOptionPane.NO_OPTION: System.exit(0); break; default: JOptionPane.showMessageDialog(null, "Invalid Response"); break; } } }
I want the Yes in the Confirm Dialog to continue to the next JOption Pane, and if they click the no I want it to exit. Once I figure out how to get the confirm dialog to work I can finish the rest easily. I just can't figure this out, can anyone help me?