import javax.swing.JOptionPane; public class DialogBoxDemo1a { public static void main( String [] args ) { String stuff = JOptionPane.showInputDialog( null, "Please type something" ); if (stuff != null) { JOptionPane.showMessageDialog( null, "You typed " + stuff ); } else { JOptionPane.showMessageDialog( null, "You pressed cancel."); }; int response = JOptionPane.showConfirmDialog(null, "Well, what do you want?"); System.out.println(response); if (response == 2){ JOptionPane.showMessageDialog(null, "You pressed cancel."); } else { if (response == 1) { JOptionPane.showMessageDialog(null, "You pressed no."); } else { //response = 0 JOptionPane.showMessageDialog(null, "You pressed OK."); } } } }