aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTextArea realtime update Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextArea realtime update" Watch "JTextArea realtime update" New topic
Author

JTextArea realtime update

Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
Hi guys

Just wondering is it possible to get a realtime update (refresh, repaint or something) of a TextArea in Swing?

I have a simple text file which will be updated with unique IDs for products by a 3rd party system, I need to display this text file in a Swing app and need it to show the text file updating as new IDs are added to it.

It doesn't have to be a TextArea nut that is what I have been trying to do this with, problem is I can only get it to update at 'loading' of the Swing app, to get the latest version of the file I have to close the app and reopen it.

Just wonder can this be doe, or do I have to tell the people who think these ideas up, the good news?

:-D
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

JTextArea # setText() ?
I am sorry. I am not sure I understand your problem. Could you please rephrase?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
My understanding is that setText() will set the text value at the point of loading the JTextArea, what I need is for the text to automatically update (refresh, repaint) as the textfile it has loaded changes.

So I have textfile A loaded in a TextArea, and the text in the file is changing every 10 seconds

A12345
B23456
C34456
etc

As a new line is in the text file, the textArea refreshes showing the new line.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

Check out JTextArea # append() and JTextComponent # read()
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

Keith Seller wrote:My understanding is that setText() will set the text value at the point of loading the JTextArea, what I need is for the text to automatically update (refresh, repaint) as the textfile it has loaded changes.

setText can be called at any time in your application's lifetime. However, I agree with Maneesh that append is better; area.append(text) is somewhat similar to area.setText(area.getText() + text).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
 
subject: JTextArea realtime update