Results 1 to 3 of 3
  1. #1
    oregon is offline Member
    Join Date
    Jul 2007
    Posts
    41
    Rep Power
    0

    Default problems with JOptionPane

    I'm using this command line and it works fine:
    Java Code:
    int age=Integer.parseInt(JOptionPane.showInputDialog("Enter your age"));
    but when i try with strings, it doesn't work
    Java Code:
    String Name=String.parseString(JOptionPane.showInputDialog("Enter your name"));
    why?

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    The String class does not have a parseString method. You can look up fields and methods available for any class in the javadocs.
    Overview (Java 2 Platform SE 5.0). Find the class in the left lower frame, click the link and its api loads into the main frame. The Method Summary lists all the methods for the class. Sections below show methods of superclasses available through inheritance.
    The showInputDialog method you are using returns a String so you only need
    Java Code:
    String Name = JOptionPane.showInputDialog("Enter your name");

  3. #3
    oregon is offline Member
    Join Date
    Jul 2007
    Posts
    41
    Rep Power
    0

Similar Threads

  1. JOptionPane (customizing)
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-14-2008, 12:39 PM
  2. Changing icon of JOptionPane
    By mew in forum New To Java
    Replies: 3
    Last Post: 12-21-2007, 08:01 AM
  3. About JOptionPane.showMessageDialog
    By jhetfield18 in forum AWT / Swing
    Replies: 2
    Last Post: 11-02-2007, 11:45 PM
  4. About JOptionPane.showMessageDialog
    By jhetfield18 in forum Advanced Java
    Replies: 0
    Last Post: 11-02-2007, 11:56 AM
  5. Problem with JOptionPane.showInputDialog()
    By romina in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 06:33 AM

Posting Permissions

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