NEWS: Total Picture Views: 151536 | Total Article Views: 161032 | Top 5 Most Popular Article: 1. Am I Stuck Algorithm with Becker Robot | 2. PickUpThings with Becker Robot | 3. How to read a JSON and work with it | 4. Encrypted Data GUI (Download .Zip) | 5. Create Wall and Things with Becker

How to use Dialog box Java

Description:

In this example I will be showing how to use the Dialog box in Java.

Code:

import javax.swing.*;

/**
 * Created by Jean-Mathieu on 3/2/2015.
 */
public class Launch {
    public static void main(String []args){
        //Input dialog box
        String fname = JOptionPane.showInputDialog("What is your first name?");
        String lname = JOptionPane.showInputDialog("What is your last name?");

        //Create the sentence you want to print
        String name = "Your name is: " + fname + " " + lname;

        //Show the sentence
        JOptionPane.showMessageDialog(null,name);
        
        //Quit the program
        System.exit(0);
    }
}
Attachments: None

Tags: Dialog Box Input

Total Views: 828

My name is Jean-Mathieu

I created this website so other people could enjoy finding useful stuff easier. If you have any question do not hesitate to contact me.

jean8mathieuCreated on 03/02/15


affiliate_link

Disclosure: We are a website that needs compensation to operate like any other website on the internet.
We may receive consideration for our reviews but we are totally unbiased and do not accept paid reviews or fake reviews claiming to be something they are not.