• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTextArea realtime update

 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11165
14
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JTextArea # setText() ?
I am sorry. I am not sure I understand your problem. Could you please rephrase?
 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11165
14
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out JTextArea # append() and JTextComponent # read()
 
Rob Spoor
Sheriff
Pie
Posts: 20659
64
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic