Java: How to use Message Dialog Box and Message Input Box

Sometimes we may need in java programming to use input box to take input from the users in the same way we may also need to show some result or data in the pop up message dialog box.

Here I have given a little example of how to show or use Message Dialog Box and Message Input Box in java.

Here in the example Message Input Box will take input from the user and show the result in Message Dialog box.

Here is the code example:

import javax.swing.*;

class jPaneTest 

{

public void jOptionPaneTest()

                   {

          String reason=JOptionPane.showInputDialog(“Please Enter Number:”);

          JOptionPane.showMessageDialog(null,”Your Marks:”+reason);

                   }

public static void main(String args[])

{

jPaneTest newTest=new jPaneTest();

newTest.jOptionPaneTest();

}

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: