• Post Reply Bookmark Topic Watch Topic
  • New Topic

Limiting characters and word wrap in JTextArea

 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there. I found some code on Sun's website that allows me to limit the number of columns and rows in a JTextArea component as follows:


This works fine...... however I still want the JTextArea to automatically line and word wrap. Using this DocumentFilter simply stops the input at the max char limit. How can I accomplish this?
Thanks for any help you can give me.
 
Brian Cole
Author
Ranch Hand
Posts: 920
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jennifer Sohl wrote:however I still want the JTextArea to automatically line and word wrap. Using this DocumentFilter simply stops the input at the max char limit. How can I accomplish this?

A DocumentFilter can restrict the content of the Document, but it has nothing to do with how that content is displayed.

Did you check JTextArea for methods that might help you? For instance, ponder setLineWrap() and setWrapStyleWord().
 
ilkin esrefli
Greenhorn
Posts: 28
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For limiting characters

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!