Hello friends,
I am writing a program in java. The screenshot of the program is as follows:
The method append (string) is undefined for the JTextFeild
As you can see above I get a red line under "append". Why is that so? I have observed that I always get it, when I use a jtext field. When I use the jtext area instead of the field, it is resolved.
Why is this so? Can anyone please guide me how to get rid of this error?
Waiting for your replies.
Kindest regards.
Red line under “append” while using program in java
Dear User,
You should read the API (Application Programming Interface). By looking at the API you can see if there is such a method there for that class. If it doesn’t have, then you simply can’t use it .
Thank you
Red line under “append” while using program in java
Hi Warren,
That error occurs because you cannot use that method using a jtextfield since it can only support single line of text. So basically it will only work in the jtextarea instead.
I would suggest, you read the API or the Application Programming Interface so that it will help you develop, learn and understand a program easily.
Red line under “append” while using program in java
Hi Warren Donaldson,
Always try to avoid appending your characters in “StringBuffer.append”. As you’ve mentioned in problem, this will put a red line under "append". Instead of that you can use the following code “strBuffer.append('a'); //. This is the same process in jTextfieldImg.append. Use ‘n’ instead of “n”. Hope this solves your issue.