Results 1 to 3 of 3
  1. #1
    Interista is offline Member
    Join Date
    Oct 2011
    Posts
    24
    Rep Power
    0

    Default Program Using JOptionPane to say Hello to the user in a pop-up window

    Hi, any ideas what I've done wrong here?

    Compiler says

    There is an error (I think at line eight). It points at the J and says cannot find symbol. I can't think what the error is though as I've copied it from a lecturer's example?

    Java Code:
    import javax.swing.JOptionPane;
    public class Hello
    {
    	public static void main (String[] args)
    		{
    			String name;
    			
    			name=JOptionPaneInputDialog(null, "What's your name?");
    			
    			JOptionPane.showMessageDialog(null, "Welcome, " + name + ", to the world of Java");
    			
    			System.exit(0);
    		}
    }

  2. #2
    ballantony is offline Member
    Join Date
    Oct 2011
    Posts
    5
    Rep Power
    0

    Default Re: Program Using JOptionPane to say Hello to the user in a pop-up window

    Line 8 should read

    name = JOptionPane.showInputDialog(null, "What's your name?");

    i.e you are calling the showInputDialog() method of the JOptionPane class. You missed out the .

  3. #3
    Interista is offline Member
    Join Date
    Oct 2011
    Posts
    24
    Rep Power
    0

    Default Re: Program Using JOptionPane to say Hello to the user in a pop-up window

    Perfect, thanks!

    Guess what! On the lecturer's example, what you said is there, stupid boggly eyes me!!!

Similar Threads

  1. Replies: 5
    Last Post: 08-15-2011, 06:10 PM
  2. Pausing game when user minimizes window
    By tecno40 in forum Java Applets
    Replies: 1
    Last Post: 12-29-2010, 05:37 PM
  3. How do i show all the values in one window(JOptionPane)??
    By Antonioj1015 in forum Advanced Java
    Replies: 1
    Last Post: 11-25-2009, 04:17 PM
  4. Replies: 1
    Last Post: 02-20-2009, 03:49 PM
  5. Replies: 1
    Last Post: 10-20-2008, 07:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •