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
Re: mulitiple textfields help
You need to test if the textfields have values before you try to use them.
when i fill in only 1 textfield i get a null pointer(because the other boxes have nothing in 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.