Advertisement
Guest User

Untitled

a guest
Mar 10th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. import javax.swing.*;
  2.  
  3. public class MyOwn {
  4.  
  5. /**
  6. * @author Noah
  7. */
  8. public static void main(String[] args) {
  9. Object[] options = {"Create Login", "Login", "Quit"};
  10. int menuOption = JOptionPane.showOptionDialog(null, "Please choose the "
  11. + "program you would like to run:","Program Menu",JOptionPane.YES_NO_CANCEL_OPTION,
  12. JOptionPane.QUESTION_MESSAGE,null,options,options[2]);
  13. boolean exit = false;
  14. while(!exit){
  15. switch (menuOption) {
  16. case 0:
  17.  
  18. String userName = JOptionPane.showInputDialog(null,"Create a username:","johndoe");
  19. String password = JOptionPane.showInputDialog(null,"Create a password:","johndoe123");
  20. exit = true;
  21. break;
  22. case 1:
  23. String userNameEntry = JOptionPane.showInputDialog(null,"Enter your username:");
  24. String passwordEntry = JOptionPane.showInputDialog(null,"Enter your password:");
  25. if (userName.equals(userNameEntry) && password.equals(passwordEntry) ) {
  26.  
  27. Object[] optionsTwo = {"Season Quiz", "Profile Analysis", "Piggy Bank"};
  28. int menuOptionTwo = JOptionPane.showOptionDialog(null, "Please choose the "
  29. + "program you would like to run:","Program Menu",JOptionPane.YES_NO_CANCEL_OPTION,
  30. JOptionPane.QUESTION_MESSAGE,null,optionsTwo,optionsTwo[2]);
  31. switch (menuOptionTwo) {
  32. case 0:
  33. System.out.println("Season Quiz");
  34. break;
  35. case 1:
  36. System.out.println("Profile Analysis");
  37. break;
  38. case 2:
  39. System.out.println("Piggy Banks");
  40. break;
  41. }
  42. }
  43. break;
  44. case 2:
  45. System.exit(0);
  46. default:
  47. break;
  48. }
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement