Just creating a test GUI program, I have got a text field for first name and a text field for last name. In my JFrame class I am trying to take the input from firstNameTextField and in return print out the last name into the lastNameTextField. This is my code for the actionPerformed�
Basically if the text in the firstText ( variable name for my textfield) matches the first name of the person in the array. Then I want to print the second name in the text field. However I am having problems getting the text from first text field.
Can anyone shed any light on this matter please? Am I doing anything wrong?
Did you create a method "firstTextequals" or is there supposed to be a dot in there somewhere? Please be careful to Post Real Code. Assuming that you wanted to write "firstText.equals", exactly what are you comparing to the values in the array?
Basically "firstText" is the variable name for the textfield, which the user types into. And whenever the user presses the search button, I want the program to take what the user typed into "firstText" and search through the array looking to see if it matches any people in array.
If it matches, I want the second name of the person to be displayed in "lastText" textfield.
I know my explanation isnt the best, so please feel free to ask further questions.
It should be in there if the user has typed something in. It is a good idea to print out the values you are comparing when things aren't working the way you think they should.
Joined: Jul 09, 2008
This is the error I get when i type something and press "search"
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at uni.NewJFrame.searchButtonActionPerformed(NewJFrame.java:104) at uni.NewJFrame.access$100(NewJFrame.java:16) at uni.NewJFrame$2.actionPerformed(NewJFrame.java:53)