import javax.swing.*;
public class InputExample{
public static void main(String[] args){
String name, lastname , test= "";
int age, day = 0;
name = JOptionPane.showInputDialog("Please enter your First Name:");
lastname = JOptionPane.showInputDialog(null,"Please enter last name", "Last Name", JOptionPane.INFORMATION_MESSAGE);
test = JOptionPane.showInputDialog(null,"Please enter last name", "Last Name", JOptionPane.CANCEL_OPTION);
int n = JOptionPane.showConfirmDialog(null, "Would you like to play games?"," Question",JOptionPane.YES_NO_OPTION);
String aa= JOptionPane.showInputDialog("Please enter your age: ");
age = Integer.parseInt(aa);
//age = Integer.parseInt(JOptionPane.showInputDialog("Please enter your age: "));
JOptionPane.showMessageDialog(null,"Hello " + name + ". You are " + age + " years old!");
} //main
} //class
Tuesday, 23 January 2018
Related Posts:
Exceptional handling example in java import java.io.*;public class ExceptionalExample { &n… Read More
Input from user and exception handling exampleimport java.io.*;//import java.util.Scanner;public class GetUserInput&… Read More
Drawing of rectangle in java package geometry.drawing;public class Rectangle extends Point {double … Read More
Drawing of square in javapackage geometry.drawing;public class Square extends Point {double edg… Read More
0 comments: