This content has been marked as final. Show 2 replies
1. This question should go into the swing forum.
2. Write your own TextArea (extends JTextArea). In this class get the document with
AbstractDocument doc = (AbstractDocument)this.getDocument();Then write your own Document filter (extends DocumentFilter) and set this filter to the document
doc.setDocumentFilter(filter)In the filter you have full control over of what is inserted in your text area.
And there's an example in the API documentation for JTextField about how to use a Document to control the input. You could easily modify that example to restrict the length of the field's data.