
Signature
Knute Johnson
email s/nospam/knute/
>> ....Once the limit has been reached I
>> still want to be able to add to it but when I do I wan the stuff at
>> the beginning to get removed.
> I do that all the time. You need to add a Document to your JTextArea.
...
> public void insertString(int offs, String str, AttributeSet a)
> throws BadLocationException {
[quoted text clipped - 5 lines]
> super.insertString(offs, str, a);
> }
Hmmm, doesn't this discard the new lines instead of the old ones (no
'revolving')? Still, it shouldn't be hard to modify insertString
to remove lines at the beginning. The trick is to remove enough
entire *lines* (not just characters) to free up space for the incoming
string. Still not too hard of a modification, 'tho.

Signature
Steve Wampler -- swampler@noao.edu
The gods that smiled on your birth are now laughing out loud.
Knute Johnson - 09 Mar 2007 18:18 GMT
>>> ....Once the limit has been reached I
>>> still want to be able to add to it but when I do I wan the stuff at
[quoted text clipped - 16 lines]
> entire *lines* (not just characters) to free up space for the incoming
> string. Still not too hard of a modification, 'tho.
Yes is does. I hope it isn't old timers that getting to me.
Kindly disregard my last post and look at this one.
//
//
// LengthLimitedDocument
//
//
package com.knutejohnson.classes;
import javax.swing.text.*;
public class LengthLimitedDocument extends PlainDocument {
protected int limit;
public LengthLimitedDocument(int limit) {
this.limit = limit;
}
public void insertString(int offs, String str, AttributeSet a)
throws BadLocationException {
super.insertString(offs, str, a);
int length = getLength();
if (length > limit)
remove(0,limit/20); // remove 5% of document if over limit
}
}

Signature
Knute Johnson
email s/nospam/knute/
SeanM - 09 Mar 2007 20:28 GMT
On Mar 9, 10:18 am, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
wrote:
> >>> ....Once the limit has been reached I
> >>> still want to be able to add to it but when I do I wan the stuff at
[quoted text clipped - 52 lines]
> Knute Johnson
> email s/nospam/knute/
Thanks, I will give this a try.
SM