Java Swing API(javax.swing) has JOptionPane class contains simple static method for different purpose. The method JOptionPane.showInputDialog() is used to take single line input from a small dialog box.
Sample Code:
import javax.swing.JOptionPane;
/**
Taking input using GUI input-dialog (Swing)
@author Vikram
*/
public class TakeGUIInput {
public static void main(String[] args) {
String name = JOptionPane.showInputDialog("Your Name: ");
String strSal = JOptionPane.showInputDialog("Enter Salary:");
Float salary = new Float(strSal);
Integer age = new Integer(JOptionPane.showInputDialog("Enter Age: "));
System.out.println("Name: "+name);
System.out.println("Salary: "+salary);
System.out.println("Age: "+age);
}
}
On this page of the site you can watch the video online 33 - Input Using Swing Input-Dialog in Java - By eZeon with a duration of hours minute second in good quality, which was uploaded by the user Vikram Thakur 19 September 2017, share the link with friends and acquaintances, this video has already been watched 1,664 times on youtube and it was liked by 10 viewers. Enjoy your viewing!