Getting Input with the JOptionPane Class - Java Language Basics

Java examples for Language Basics:Hello World

Description

Getting Input with the JOptionPane Class

Demo Code

import javax.swing.JOptionPane;

public class DialogApp
{
  public static void main(String[] args)
  {/*from   w w w  .jav  a  2 s  .  com*/
    String s = JOptionPane.showInputDialog("Enter an integer:");
    int x = Integer.parseInt(s);
    System.out.println("You entered " + x + ".");
  }

}

Related Tutorials