Results 1 to 9 of 9
  1. #1
    mDennis10 is offline Member
    Join Date
    Jul 2011
    Posts
    76
    Rep Power
    0

    Default Texfield numeric Input

    i am new to java and want to know how to take numeric input from a JTextField and do calculations with it and then display it back into a new textField.

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

    Default

    At what step are you stuck? I assume that you know how to get text out of and put text into a JTextField, right? Are you stuck at parsing the String into a number?

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

    Default

    And are you going to post your question and ignore all replies just as you did in your previous thread: Components not displaying on JFrame

    If so, why bother replying if you're not going to reply back and acknowledge help given?

  4. #4
    mDennis10 is offline Member
    Join Date
    Jul 2011
    Posts
    76
    Rep Power
    0

    Default

    i don't even know how to parse String into a number

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

    Default

    Quote Originally Posted by mDennis10 View Post
    i don't even know how to parse String into a number
    Google can help you but for now look here: JRJC - How To Convert a String to an int.

    And also, please reply to the kind folks who helped you in your previous thread. This is certainly not asking too much of you, you think?

  6. #6
    mDennis10 is offline Member
    Join Date
    Jul 2011
    Posts
    76
    Rep Power
    0

    Default

    i have an idea how to do this now.First i should parse the string input to an integer, then do my calculations,after doing my calculation parse the result back to a string, then display it in a textField.

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

    Default

    Quote Originally Posted by mDennis10 View Post
    i have an idea how to do this now.First i should parse the string input to an integer, then do my calculations,after doing my calculation parse the result back to a string, then display it in a textField.
    That should work, although when translating a number back to a String, I don't think it's called parsing, but perhaps formatting, though I'm not sure. How you parse and format will depend on what type of numbers you are using be they ints, doubles, or what-nots.

  8. #8
    mDennis10 is offline Member
    Join Date
    Jul 2011
    Posts
    76
    Rep Power
    0

    Default

    Quote Originally Posted by Fubarable View Post
    That should work, although when translating a number back to a String, I don't think it's called parsing, but perhaps formatting, though I'm not sure. How you parse and format will depend on what type of numbers you are using be they ints, doubles, or what-nots.
    ok thanks alot

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

    Default

    Quote Originally Posted by mDennis10 View Post
    ok thanks alot
    You're welcome, but again, please reply to the folks who helped you in your previous thread that I've linked to above in my second post in this thread.

Similar Threads

  1. Set TexField to false
    By globo in forum New To Java
    Replies: 3
    Last Post: 11-18-2010, 09:46 PM
  2. Index out of bounds Numeric analyzer.
    By Sean_J in forum New To Java
    Replies: 3
    Last Post: 03-17-2010, 04:06 PM
  3. JXL, Numeric data issue
    By only2008 in forum Java Servlet
    Replies: 0
    Last Post: 02-27-2009, 12:36 PM
  4. get numeric value from a text field
    By Lehane_9 in forum New To Java
    Replies: 2
    Last Post: 06-14-2008, 04:19 AM
  5. Allowing only numeric values in a TextField
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-01-2008, 11:08 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
  •