Reputation: 5640
I have a JTextArea and I need to take each one of the field's characters to translate it into another. But for this purpose I need to browse in the JTextArea.
So I thought of a simple loop like:
for(int i = 0; i <= t.length(); i++) { ... }
but the length()
function is not appropriate and I can't find one which is.
If anyone has already encountered this problem, I'd like a bit of help with it.
Upvotes: 2
Views: 3970
Reputation: 3040
you can use the length function in the Text of the jTextArea like this
jTextField.getText().length()
Upvotes: 2
Reputation: 19791
If you need the String content of a JTextArea
field just use textArea.getText()
, and then use that string as you usually do, e.g. getting its length with length()
.
Upvotes: 3