Justis Peters wrote:

Before I make my suggestion, let me offer this caveat: I write mostly back-end code and web applications. I have never before worked with Swing.

Likewise, here.


With that said, though, I think I can offer an easy solution that will let the garbage collector do the work of keeping your memory usage down.
> This solution simply extends JTextArea and overrides append(String)
> with something that monitors length on your behalf.

I almost did the same thing, but it seemed like overkill for this quick 'n dirty little monitor thing. But I like what you came up with.


If you were doing this in a more permanent fashion or if you knew
> you would later want to use this same concept on other subclasses of JTextComponent,
> you would be better to do this as a separate object (instead of a subclass).



I wound up just implementing a utility method in the main class of the program.. yeah, yeah, I know... but this is, again, basically a one off
little utility not something: A. mission critical, or B. likely to be
reused.


> You could then have that object register for events with the
> JTextArea and then trim off the excess text as needed.
>

My first pass at fixing this was based on that approach, but didn't
work (no doubt due to some lack of understand of Swing on my
behalf).  What I encountered was an IllegalStateException if
I tried to modify the document inside the listener.  There's
probably a way to do it, but I'm pretty clueless when it comes
to Swing, and I have something that works now, so I'll probably
let it rest unless I get *really* bored one day. :-)


TTYL,

Phil
--
Vote Badnarik for President 2004
www.badnarik.org

FREE AMERICA
Vote Libertarian
www.lp.org

_______________________________________________
Juglist mailing list
[EMAIL PROTECTED]
http://trijug.org/mailman/listinfo/juglist_trijug.org

Reply via email to