Displays an input dialog - Java Swing

Java examples for Swing:JOptionPane

Introduction

Ask the user to enter some text about JOptionPane

Demo Code

import javax.swing.JOptionPane;

public class Main {
  public static void main(String[] args) {
    String response = JOptionPane
        .showInputDialog("Please enter your opinion about input dialog.");

    if (response == null) {
      System.out.println("You have cancelled the input dialog.");
    } else {//from w w  w .j a v  a 2  s  .co  m
      System.out.println("You entered: " + response);
    }
  }
}

Related Tutorials