This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
try this --- setDocument() ... Document class - insertString(...) method
Posted by ping203 on February 08, 2002 at 10:26 AM
try this JtextArea1.setDocument(new MaxSizeDocument() extends PlainDocument { public void insertString(int offset, String string, AttributeSet attributes) throws BadLocationException { if (string == null) { return; } else { int textArealength = getLength(); int newStringLength = string.length(); if (MAX_SIZE < (textArealength + newStringLength)) return; //reach limit super.insertString(offset, string, attributes); } }//end method });
Replies:
|