Hello, Just go through the below scenario and suggest me to solve it. I developed a frame which consists of two textfields. These are of JTextField object types. It also consists of two buttons 'Next' and 'Report' of type JButton. One textfield will read a question from a .txt file and the question will be displayed on the text field. The user will enter the answer in another textfield. We will compare the answer with the expected answer and we will calculate the percentage. After entering the answer if the user clicks the 'Next' button next question will be displayed. My problem is I am not able to retrieve the user answer from the textfield to compare it with the expected answer. I request to help me in solving this problem.
Hello, Thanks for your suggestion. I tried to retrieve the text using getText() method but I am not able to get. I forgot to mention in the earlier mail that I had tried using getText() method. I used String userans = txtfield.getText(); but not getting. Is there any other way to do it.
I think u are using getText() before the action of the button click is happening(Or before the text itself is entered). Logically the user should enter his answer in the text field and then hits Enter or clicks on the Next Button. In this action handling, you should retrieve the text and then proceed with other tasks.
Or this is what you r doing and still unable to get the text?
if so, then plz try to share the piece of code...!
Also I would suggest to set some trial text by using setText() and try to get this one by getText() somewhere , print on console and do some trial nd error stuff.
"Thinking of doing something is also doing something ...so don't just stop thinking!"