🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #9653

Re: JOptionPane.showInternalConfirmDialog() getValue() method dosnt work??

#9653
From: John P. McGrath
Date: Thu, 10 Feb 2000 00:00
32 lines
1758 bytes
On Thu, 10 Feb 2000 17:37:16 -0500, Kingsley wrote:

> im using a JTextArea to display text messages. im appending 
> strings line by line.
> 
> as the message grows beyond a certain limit (say 40 lines
> of text or beyond the viewing area) the messages at the top
> should get deleted and the new messages should be appended
> to the bottom.
> 
> can any one give me possible solution or an idea !

One approach would be to get the Document for the JTextArea, add a 
DocumentListener to it, and then remove text when you get an event with 
eventType == INSERT.

Another approach would be to subclass JTextArea, override the append() 
method (I assume that is what you are using) and automatically remove 
text when text is added.

Another would be to create your own Document class that holds a fixed 
number of lines of text.  This would best be accomplished by subclassing 
AbstractDocument or PlainDocument.

I am not sure which would be best for you.  It would probably depend at 
least partially on whether you really need an exact number of lines, or 
just want to keep the storage requirements from growing too large.

-- 
John P. McGrath
<JPMcGrath@fast.net>
<jpm@nscs.fast.net>
Technical Details
Message-ID: <MPG.130d587df87f2e0b989784@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <86960s$ibp7@bornews.borland.com> <87vdpo$cr018@bornews.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,569c179d91546360
X-Google-Attributes: gid111d45,public
From: John P. McGrath <JPMcGrath@fast.net>
Subject: Re: JOptionPane.showInternalConfirmDialog()   getValue() method dosnt work??
Date: 2000/02/10
Message-ID: <MPG.130d587df87f2e0b989784@forums.borland.com>
X-Deja-AN: 584411287
References: <86960s$ibp7@bornews.borland.com> <87vdpo$cr018@bornews.borland.com>
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.swing