JOptionPane – Swing with Java

I just love the Swing library of Java for desktop GUI development. Here’s a very simple example of JOptionPane that prompts for the user’s name and then displays it inside another dialog box.

import javax.swing.JOptionPane;
 
public class masnun {
 
		public static void main(String args[]) {
 
					String Name = JOptionPane.showInputDialog("What is your name? ");
					JOptionPane.showMessageDialog(null,"Your name is " + Name);
 
 
			}
 
 
}

Save it as “masnun.java” and run after compilation :D It’s really cool !

This entry was posted in Blog Post and tagged . Bookmark the permalink.

2 Responses to JOptionPane – Swing with Java

  1. Pingback: Tweets that mention JOptionPane – Swing with Java | maSnun.com -- Topsy.com

  2. gifer says:

    nice post thanks bro..:)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">