Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: mulitiple textfields help

  1. #1
    Member
    Join Date
    May 2011
    Location
    west palm beach, FL
    Posts
    189
    My Mood
    Tired
    Thanks
    41
    Thanked 11 Times in 10 Posts

    Default mulitiple textfields help

    hi im making a small program for some calculations and ive ran into a wall...ill show a picture of the program so i can explain easier

    so i have 5 jtextfields and i cant figure out how i can just put info in 1 instead of putting info in all 5...when i fill in only 1 textfield i get a null pointer(because the other boxes have nothing in them) when i click the calc button but if i have all text fields filled it works fine

    so is it possible to have only 1 textfield filled in at a time? if so can you point me in the right direction? thanks a lot for any help you can give
    Attached Images Attached Images


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: mulitiple textfields help

    when i fill in only 1 textfield i get a null pointer(because the other boxes have nothing in them)
    You need to test if the textfields have values before you try to use them.
    Get the contents of each text field and test that there is good data before using it.
    Use an if statement to test the value and skip over working with the empty data.

Similar Threads

  1. API Jena - Fill textfields with values of DatatypeProperties
    By bpr25 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: August 8th, 2011, 11:37 AM
  2. labels,textfields,buttons
    By balu424525 in forum AWT / Java Swing
    Replies: 1
    Last Post: June 26th, 2011, 07:44 AM
  3. Problem veiwing textfields in applet
    By danwoods in forum AWT / Java Swing
    Replies: 0
    Last Post: October 21st, 2009, 02:34 AM
  4. Exception handling for TextFields
    By FretDancer69 in forum AWT / Java Swing
    Replies: 1
    Last Post: June 16th, 2009, 07:48 AM