使用JOptionPane类获取输入
import javax.swing.JOptionPane;/** nowjava - 时代Java 提供 **/ public class DialogApp { public static void main(String[] args) { String s = JOptionPane.showInputDialog("Enter an integer:"); int x = Integer.parseInt(s); System.out.println("You entered " + x + "."); } }