JOptionPane Class static Method showInputDialog

Line 10 uses JOptionPane method showInputDialog to display an input dialog containing a prompt and a field (known as a text field) in which the user can enter text. Method showInputDialog’s argument is the prompt that indicates what the user should enter. The user types characters in the text field, then clicks the OK button or presses the Enter key to return the String to the program. Method showInputDialog returns a String containing the characters typed by the user. We store the String in variable name. If you press the dialog’s Cancel button or press the Esc key, the method returns null and the program displays the word “null” as the name.

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.