• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

refreshing the jframe[urgent]

 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm using a JFrame containing a JTextarea.I'm displaying the list of files in the specified folder (i.e. appending it to the jtextarea).When the system is processing it does not display the updated containers.Moreover if we switch to some other application & return to it,the jframe is fully blank until the files are completely found.I want to add to the list whenever each file is found & stop it intermediately.Please reply me as soon as possible.
Happy middling with java.
Bye from Netharam.
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like you are executing a long process on the same thread that is used to refresh the GUI components in your application. Essentially what you need to do is spawn a new thread to do your file processing for you. This way, the GUI thread is free to perform whatever updates (repaints) that it needs to do without having to wait for your processing to finish.
Spawning a new thread will make it easy for you to also update the data in your components while the processing is happening. For example, if you receive a file name from your process, you can append that to the JTextArea and it will be displayed WHILE your process is off getting the next file name. You can also stop your processing by pressing a button or otherwise interacting with the GUI if you use a thread.
Hope this helps!
 
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If you search for "Swing Worker" on the sun site you'll find a very handy implementation of background threads specially designed for swing by people at Sun.
I had similar problems with a data access interface and this worked a treat - and it was easy to drop into event methods too
Hope that helps,
 
We don't have time to be charming! Quick, read this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!