Wednesday, April 30, 2014

Text Area can not be resolved or is not a field.
































































































































In my application, some text should be added to a text area in response to a click on a button. So as an action listener to this class, I made another class which implements the ActionListener.
































































































































Inside this class, I have obtained the text which I want to be added to the text area. But the text area is in another class and for the action listener I wrote another class.
































































































































Now the problem is that when I try to add the text to the text area by the following line of code, it says that textArea_1 can not be resolved or is not a field.
































































































































































































Java Code:







































































































































ParentPanel.textArea_1.setText("Name:"+ncrarray[0]+"\nCode:"+ncrarray[1]+"\nRank:"+ncrarray[2]);





































































































































What should I do about it?































































_________________________________________
































































































































Even if I try to write a method like the following in the class in which the text area is created, it gives the same error.
































































































































































































Java Code:







































































































































public void printTextArea(String text) {
textArea_1.setText(text);
}





































































































































NOTE:- The text area is present inside a constructor of the class. I am writing the method outside the constructor (ofcourse).






























































































































































































No comments:

Post a Comment