JOptionPane help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jek339
    New Member
    • Jul 2006
    • 1

    #1

    JOptionPane help

    Hey, I'm totally new to Java, and I'm taking a class. My current assignment involves inputting 2 names and corresponding bdays for each name using the JOptionPane.sho wInputDialog etc. Anyway, I'm confused by Sun's site and I keep getting error messages. Below is what I have and the error message when I try to compile. Any help would be much appreciated. Thanks!

    package javaapplication 1;

    /**
    *
    * @author Jillian
    */
    public class asg1 {
    //This is a programme designed to output older or younger.
    public static void main(String[] args) {
    System.out.prin tln("Author: Jillian);
    int name1 = JOptionPane.sho wInputDialog("I nput the first name:");
    }

    }

    symbol : variable JOptionPane
    location: class javaapplication 1.asg10
    int name1 = JOptionPane.sho wInputDialog("I nput the first name:");
    1 error
    BUILD FAILED (total time: 3 seconds)
  • heat84
    New Member
    • Nov 2007
    • 118

    #2
    Originally posted by jek339
    Hey, I'm totally new to Java, and I'm taking a class. My current assignment involves inputting 2 names and corresponding bdays for each name using the JOptionPane.sho wInputDialog etc. Anyway, I'm confused by Sun's site and I keep getting error messages. Below is what I have and the error message when I try to compile. Any help would be much appreciated. Thanks!

    package javaapplication 1;

    /**
    *
    * @author Jillian
    */
    public class asg1 {
    //This is a programme designed to output older or younger.
    public static void main(String[] args) {
    System.out.prin tln("Author: Jillian);
    int name1 = JOptionPane.sho wInputDialog("I nput the first name:");
    }

    }

    symbol : variable JOptionPane
    location: class javaapplication 1.asg10
    int name1 = JOptionPane.sho wInputDialog("I nput the first name:");
    1 error
    BUILD FAILED (total time: 3 seconds)

    The JOptionPane.sho wInputDialog method returns a string so instead of int name1 it should be String name one or alternatively you can parse the string and make the variable name1 an integer.

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by heat84
      The JOptionPane.sho wInputDialog method returns a string so instead of int name1 it should be String name one or alternatively you can parse the string and make the variable name1 an integer.
      An even more worrying thing is that JOptionPane itself was never imported. It is in the javax.swing package.

      Comment

      Working...