/** get a string from the user using a dialog box. @author Greg Vogl 2003-09-21 */ import javax.swing.JOptionPane; // the library that contains the dialog box public class DialogString { /** get a string from the user using a dialog box.
input: a string using a dialog box
output: the string */ public static void main (String[] args) { String input = JOptionPane.showInputDialog("Enter a string"); System.out.println("You entered: " + input); System.exit(0); // needed to exit a program with a GUI thread } }