Red line under “append” while using program in java

Asked By 0 points N/A Posted on -
qa-featured

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

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.

SHARE
Best Answer by Agail etthan
Answered By 0 points N/A #151031

Red line under “append” while using program in java

qa-featured

 

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

Best Answer
Best Answer
Answered By 0 points N/A #151032

Red line under “append” while using program in java

qa-featured

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.

Answered By 5 points N/A #151033

Red line under “append” while using program in java

qa-featured

 

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.

Related Questions