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?
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
As a new line is in the text file, the textArea refreshes showing the new line.
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).