Results 1 to 3 of 3
  1. #1
    Renegade85 is offline Member
    Join Date
    Nov 2007
    Posts
    25
    Rep Power
    0

    Default [SOLVED] How to check what type of value entered in text field

    Hi, is there anyway to make sure that an int is the data type entered in a text field?

    Thanks

  2. #2
    danielstoner's Avatar
    danielstoner is offline Senior Member
    Join Date
    Apr 2008
    Location
    Canada
    Posts
    191
    Rep Power
    10

    Default

    Yes. Try to parse the String from the text field with Integer.parseInt(String s). If you get a NumberFormatException exception then it wasn't an int so you can act on that information.
    Daniel @ [www.littletutorials.com]
    Language is froth on the surface of thought

  3. #3
    Renegade85 is offline Member
    Join Date
    Nov 2007
    Posts
    25
    Rep Power
    0

Similar Threads

  1. get numeric value from a text field
    By Lehane_9 in forum New To Java
    Replies: 2
    Last Post: 06-14-2008, 03:19 AM
  2. Using reflection to check array type and length
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-23-2008, 08:15 PM
  3. Using reflection to check array type and length
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-14-2008, 08:42 PM
  4. FInal field cannot be assigned
    By ravian in forum New To Java
    Replies: 3
    Last Post: 12-13-2007, 03:26 PM
  5. Waste Space & Text Field
    By Gajesh Tripathi in forum AWT / Swing
    Replies: 2
    Last Post: 12-01-2007, 08:44 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
  •