Guest User

Untitled

a guest
Oct 16th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. public class test{
  2. public static void main(String[] args){
  3.  
  4. //default icon, custom title
  5. int n = JOptionPane.showConfirmDialog(
  6. null,
  7. "Would you like green eggs and ham?",
  8. "An Inane Question",
  9. JOptionPane.YES_NO_OPTION);
  10.  
  11. if(true){
  12. JOptionPane.showMessageDialog(null, "HELLO");
  13. }
  14. else {
  15. JOptionPane.showMessageDialog(null, "GOODBYE");
  16. }
  17.  
  18. System.exit(0);
  19. }
  20. }
  21.  
  22. int reply = JOptionPane.showConfirmDialog(null, message, title, JOptionPane.YES_NO_OPTION);
  23. if (reply == JOptionPane.YES_OPTION) {
  24. JOptionPane.showMessageDialog(null, "HELLO");
  25. }
  26. else {
  27. JOptionPane.showMessageDialog(null, "GOODBYE");
  28. System.exit(0);
  29. }
  30.  
  31. if(n == JOptionPane.YES_OPTION)
  32. {
  33. JOptionPane.showMessageDialog(null, "HELLO");
  34. }
  35. else
  36. {
  37. JOptionPane.showMessageDialog(null, "GOODBYE");
  38. }
  39.  
  40. int test = JOptionPane.showConfirmDialog(null, "Would you like green eggs and ham?", "An insane question!");
  41. switch(test) {
  42. case 0: JOptionPane.showMessageDialog(null, "HELLO!"); //Yes option
  43. case 1: JOptionPane.showMessageDialog(null, "GOODBYE!"); //No option
  44. case 2: JOptionPane.showMessageDialog(null, "GOODBYE!"); //Cancel option
  45. }
  46.  
  47. int n = JOptionPane.showConfirmDialog(
  48. null,
  49. "sample question?!" ,
  50. "",
  51. JOptionPane.YES_NO_OPTION);
  52.  
  53. if(n == JOptionPane.YES_OPTION)
  54. {
  55. JOptionPane.showMessageDialog(null, "Opening...");
  56. }
  57. else
  58. {
  59. JOptionPane.showMessageDialog(null, "Goodbye");
  60. System.exit(0);
  61.  
  62. //default icon, custom title
  63. int n = JOptionPane.showConfirmDialog(null,"Would you like green eggs and ham?","An Inane Question",JOptionPane.YES_NO_OPTION);
  64.  
  65. String result = "?";
  66. switch (n) {
  67. case JOptionPane.YES_OPTION:
  68. result = "YES";
  69. break;
  70. case JOptionPane.NO_OPTION:
  71. result = "NO";
  72. break;
  73. default:
  74. ;
  75. }
  76. System.out.println("Replace? " + result);
  77.  
  78. int n = JOptionPane.showConfirmDialog(null, "Yes No Cancel", "YesNoCancel", JOptionPane.YES_NO_CANCEL_OPTION);
  79. if(n == 0)
  80. {
  81. JOptionPane.showConfirmDialog(null, "You pressed YESn"+"Pressed value is = "+n);
  82. }
  83. else if(n == 1)
  84. {
  85. JOptionPane.showConfirmDialog(null, "You pressed NOn"+"Pressed value is = "+n);
  86. }
  87. else if (n == 2)
  88. {
  89. JOptionPane.showConfirmDialog(null, "You pressed CANCELn"+"Pressed value is = "+n);
  90. }
  91. else if (n == -1)
  92. {
  93. JOptionPane.showConfirmDialog(null, "You pressed Xn"+"Pressed value is = "+n);
  94. }
  95.  
  96. int n = JOptionPane.showConfirmDialog(null, "Yes No Cancel", "YesNoCancel", JOptionPane.YES_NO_CANCEL_OPTION);
  97. switch (n) {
  98. case 0:
  99. JOptionPane.showConfirmDialog(null, "You pressed YESn"+"Pressed value is = "+n);
  100. break;
  101. case 1:
  102. JOptionPane.showConfirmDialog(null, "You pressed NOn"+"Pressed value is = "+n);
  103. break;
  104. case 2:
  105. JOptionPane.showConfirmDialog(null, "You pressed CANCELn"+"Pressed value is = "+n);
  106. break;
  107. case -1:
  108. JOptionPane.showConfirmDialog(null, "You pressed Xn"+"Pressed value is = "+n);
  109. break;
  110. default:
  111. break;
  112. }
Add Comment
Please, Sign In to add comment