Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class test{
- public static void main(String[] args){
- //default icon, custom title
- int n = JOptionPane.showConfirmDialog(
- null,
- "Would you like green eggs and ham?",
- "An Inane Question",
- JOptionPane.YES_NO_OPTION);
- if(true){
- JOptionPane.showMessageDialog(null, "HELLO");
- }
- else {
- JOptionPane.showMessageDialog(null, "GOODBYE");
- }
- System.exit(0);
- }
- }
- int reply = JOptionPane.showConfirmDialog(null, message, title, JOptionPane.YES_NO_OPTION);
- if (reply == JOptionPane.YES_OPTION) {
- JOptionPane.showMessageDialog(null, "HELLO");
- }
- else {
- JOptionPane.showMessageDialog(null, "GOODBYE");
- System.exit(0);
- }
- if(n == JOptionPane.YES_OPTION)
- {
- JOptionPane.showMessageDialog(null, "HELLO");
- }
- else
- {
- JOptionPane.showMessageDialog(null, "GOODBYE");
- }
- int test = JOptionPane.showConfirmDialog(null, "Would you like green eggs and ham?", "An insane question!");
- switch(test) {
- case 0: JOptionPane.showMessageDialog(null, "HELLO!"); //Yes option
- case 1: JOptionPane.showMessageDialog(null, "GOODBYE!"); //No option
- case 2: JOptionPane.showMessageDialog(null, "GOODBYE!"); //Cancel option
- }
- int n = JOptionPane.showConfirmDialog(
- null,
- "sample question?!" ,
- "",
- JOptionPane.YES_NO_OPTION);
- if(n == JOptionPane.YES_OPTION)
- {
- JOptionPane.showMessageDialog(null, "Opening...");
- }
- else
- {
- JOptionPane.showMessageDialog(null, "Goodbye");
- System.exit(0);
- //default icon, custom title
- int n = JOptionPane.showConfirmDialog(null,"Would you like green eggs and ham?","An Inane Question",JOptionPane.YES_NO_OPTION);
- String result = "?";
- switch (n) {
- case JOptionPane.YES_OPTION:
- result = "YES";
- break;
- case JOptionPane.NO_OPTION:
- result = "NO";
- break;
- default:
- ;
- }
- System.out.println("Replace? " + result);
- int n = JOptionPane.showConfirmDialog(null, "Yes No Cancel", "YesNoCancel", JOptionPane.YES_NO_CANCEL_OPTION);
- if(n == 0)
- {
- JOptionPane.showConfirmDialog(null, "You pressed YESn"+"Pressed value is = "+n);
- }
- else if(n == 1)
- {
- JOptionPane.showConfirmDialog(null, "You pressed NOn"+"Pressed value is = "+n);
- }
- else if (n == 2)
- {
- JOptionPane.showConfirmDialog(null, "You pressed CANCELn"+"Pressed value is = "+n);
- }
- else if (n == -1)
- {
- JOptionPane.showConfirmDialog(null, "You pressed Xn"+"Pressed value is = "+n);
- }
- int n = JOptionPane.showConfirmDialog(null, "Yes No Cancel", "YesNoCancel", JOptionPane.YES_NO_CANCEL_OPTION);
- switch (n) {
- case 0:
- JOptionPane.showConfirmDialog(null, "You pressed YESn"+"Pressed value is = "+n);
- break;
- case 1:
- JOptionPane.showConfirmDialog(null, "You pressed NOn"+"Pressed value is = "+n);
- break;
- case 2:
- JOptionPane.showConfirmDialog(null, "You pressed CANCELn"+"Pressed value is = "+n);
- break;
- case -1:
- JOptionPane.showConfirmDialog(null, "You pressed Xn"+"Pressed value is = "+n);
- break;
- default:
- break;
- }
Add Comment
Please, Sign In to add comment