JTextArea: Limit number of characters

1072185 pts.
Tags:
Java
Oracle
For Java, would I be able to limit the amount of characters in a JTextArea row? Afterwards, I also need it to go into the second row too. Appreciate it.

Answer Wiki

Thanks. We'll let you know when a new response is added.
You can simply achieve that  by using the setWrapStyleWord  and setLinewrap methods:
textarea.setWrapStyleWord(true);
textarea.setLineWrap(true);
You'll also want to set the column count of the JTextArea:
private static final int TA_ROWS = 20;
private static final int TA_COLS = 35;

private JTextArea textarea = new JTextArea(TA_ROWS, TA_COLS);

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: