How do I get the number of characters in the JTextArea?

I have a JTextArea and I need to take each of the field characters in order to translate it to another. But for this I need to browse in the JTextArea.

So, I thought of a simple scheme:

for(int i = 0; i <= t.length(); i++) { ... }

      

but the function length()

doesn't fit and I can't find it.

If anyone has encountered this problem already, I would like to help a little with it.

+3


source to share


2 answers


If you require the content of the String in a field JTextArea

, just use textArea.getText()

and then use that string as usual, eg. getting its length with length()

.



+4


source


you can use length function in jTextArea text like this



jTextField.getText().length()

      

+3


source







All Articles