Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2009
    Posts
    15
    Rep Power
    0

    Smile [SOLVED] JOptionPane String to int question

    Java Code:
    public class Opties{
              String var1 = JOptionPane.showInputDialog("blablabla");
              String var2 = JOptionPane.showInputDialog("blablalba");
              String var3 = JOptionPane.showInputDialog("blablaba");
             }
    But I donīt want a string, I want an integer. So every time I want to change String var1 to int var1 it gives me the following error message: " incompatibla types - found java.lang.String but expected int" Any way to work around this problem?

    grtz
    Last edited by blackstormattack; 03-08-2009 at 01:24 AM.

  2. #2
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    Java Code:
    int anInt = Integer.parseInt(var1);

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Better yet, create a JPanel that holds several JTextFields that will allow the user to enter several bits of data into the app all at once, and place this JPanel into a JOptionPane and show it.

  4. #4
    Join Date
    Mar 2009
    Posts
    15
    Rep Power
    0

Similar Threads

  1. String to Expression? calculator app question
    By Belbis in forum New To Java
    Replies: 2
    Last Post: 12-24-2008, 08:13 AM
  2. JOptionPane
    By Mir in forum New To Java
    Replies: 5
    Last Post: 11-29-2008, 03:04 AM
  3. JOptionPane
    By whosadork in forum New To Java
    Replies: 2
    Last Post: 10-23-2008, 03:17 AM
  4. String array for Choice, JOptionPane doesn't show
    By themburu in forum Java Applets
    Replies: 5
    Last Post: 05-29-2008, 02:10 PM
  5. question on string tokenizer
    By munigantipraveen in forum New To Java
    Replies: 2
    Last Post: 05-23-2008, 06:00 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
  •