Create a input dialog with JOptionPane in Java
Description
The following code shows how to create a input dialog with JOptionPane.
Example
import javax.swing.JOptionPane;
/*from w w w . ja v a 2 s . c o m*/
public class Main {
public static void main(String[] args) {
String s;
s = JOptionPane.showInputDialog("Enter an integer:");
int x = Integer.parseInt(s);
System.out.println("You entered " + x + ".");
}
}
The code above generates the following result.
Home »
Java Tutorial »
Swing »
Java Tutorial »
Swing »