// Ask user for name, // then greet that person. // Obtain input with input dialog; // show output with output dialog. import javax.swing.JOptionPane; public class Greeter1 { public static void main(String[] args) { // Declare name. String name; // Ask for name in input box. name = JOptionPane.showInputDialog(null, "Enter your name."); // Show message box with greeting. JOptionPane.showMessageDialog(null, "Hello, " + name + "."); } } // Prompt in input dialog: Enter your name: // Sample input to input dialog: Bob // Output message in message dialog: Hello, Bob.