import javax.swing.*; class ShowShowInputDialog { public static void main(String [] args) { while (true) { String s = JOptionPane.showInputDialog("What is this course?"); int result = JOptionPane.showConfirmDialog(null, "Your answer was \"" + s + "\". OK?"); if (result == JOptionPane.YES_OPTION) { JOptionPane.showMessageDialog(null,"This course is " + s + "." ); break; } if (result == JOptionPane.CANCEL_OPTION) break; } System.exit(0); } }